Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set transparency/alpha level in a seaborn pointplot?

I want to make a seaborn pointplot that has transparency so that I can clearly see the points located behind others of a different color.

I tried adding "alpha=0.3" to the call to pointplot and also tried the same within a catplot with kind='point'; however, neither of these results in the desired transparency (no error message is produced either).

sns.pointplot(x='aamm', y='posrate', hue='AA:XX', hue_order=[1,0], data=data, dodge=True, palette=palette, alpha=0.3)

I was hoping to get a plot with transparent points, but instead, I got one with normal opaque points. The dodge option doesn't seem to produce any noticeable effect either, in terms of separating overlapping points of different color.

Is there a way to add transparency to a seaborn pointplot or use something else to get a similar effect?

Thank you.

like image 724
chprgia Avatar asked May 24 '19 22:05

chprgia


People also ask

How do I set transparency in Seaborn?

Setting transparent background To set a transparent background you could use the RGBA tuple (0,0,0,0) , where the last 0 represents an opacity of 0 .

What is Factorplot in Seaborn?

Factor Plot is used to draw a different types of categorical plot . The default plot that is shown is a point plot, but we can plot other seaborn categorical plots by using of kind parameter, like box plots, violin plots, bar plots, or strip plots.

How do you change markers in Seaborn?

Changing Marker Color on a Scatter Plot Behind the scenes, Seaborn scatter plots use the Matplotlib color styles. Here are the color codes for the basic colors you can use for your scatter plot markers. Pass the value in the argument column to the color parameter to change your marker colors.

What is Pointplot in Seaborn?

Since it is built on top of the matplotlib. pyplot library, Seaborn can easily be linked with libraries like pandas. A point plot uses scatter plot glyphs to visualize features like point estimates and confidence intervals. A point plot uses scatter plot points to represent the central tendency of numeric data.


1 Answers

To the extent of my knowledge there is no more an alpha parameter that can be directly set in seaborn.

You can do the following thou:

Sample dataframe

df = pd.DataFrame(np.random.randint(low=0, high=1000, size=(50, 5)))

Plotting

g=sns.pointplot(x=0, y=1, data=df, dodge=True,plot_kws=dict(alpha=0.3))
plt.setp(g.collections, alpha=.3) #for the markers
plt.setp(g.lines, alpha=.3)       #for the lines

output

like image 54
CAPSLOCK Avatar answered Sep 23 '22 20:09

CAPSLOCK