Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change spot edge colors in seaborn scatter plots

I have created a scatter plot using seaborn:

import seaborn as sns sns.set(style="ticks", color_codes=True)          g=sns.scatterplot(x="length", y="coverage", data=df, hue = 'Products', edgecolors=None, alpha = 0.7) g.set(yscale="log") plt.xlabel("Length(bp)") plt.ylabel("Coverage") plt.legend(loc = 'lower right') plt.savefig('ATN_plot.png',dpi = 600) 

The original data(Partial):

contig  length  coverage    pathway Products 53  1230    2423    stigmatellin    Yes 58  1195    885 curacin Yes 65  1161    598 jamaicamide Yes 68  1159    8001    jamaicamide Yes 79  1113    1423    curacin Yes 105 1042    1106    stigmatellin    Yes 727 666 223 HSAF (heat stable antifungal factor)    Yes 787 655 37  curacin Yes 791 654 13  stigmatellin    Yes 798 652 49  stigmatellin    Yes 844 642 5774    jamaicamide Yes 89  1090    13  No  No 90  1089    10  No  No 91  1086    26  No  No 92  1080    16  No  No 93  1079    10  No  No 94  1079    13  No  No 

And the final plot looks like this:

enter image description here

I don't like the white edge of the spots. The left bottom part of the image where most spots are accumulated looks too white. I already included edgecolors=None in my code but it seems not working. Does anyone know how to remove the edge color or change it to others?

like image 757
Steve Xu Avatar asked Oct 23 '18 23:10

Steve Xu


People also ask

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.

How do you change marker size in Seaborn?

To set the size of markers, we can use the s parameter. This parameter can be used since seaborn is built on the matplotlib module. We can specify this argument in the scatterplot() function and set it to some value. Alternatively, we can control the size of the points based on some variables.

How do I change the shape of scatter points in Seaborn?

In Seaborn's scatterplot() function, we can change the shape of markers by a variable using style argument. In this example, we have changed the marker's shape based on the value of the variable, “sex” in the dataframe. Notice that data points corresponding to males are different from females.

What is Scatter_kws?

Show activity on this post. Those are linked to the plot and line that appear in the figure. If we use scatter_kws={"s": 780} meaning the greater value given, the greater plot/node. If we use line_kws={"lw":5} meaning the greater the value given, the thicker the line.


1 Answers

Replace edgecolors=None with linewidth=0

Something like:

g=sns.scatterplot(x="length", y="coverage", data=df, hue = 'Products',                    linewidth=0, alpha = 0.7) 
like image 100
Lucas Avatar answered Oct 11 '22 14:10

Lucas