Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

pandas - Why the point size using sns.lmplot is different when I used plt.scatter?

I want to do a scatterplot according x and y variables, and the points size depend of a numeric variable and the color of every point depend of a categorical variable.

First, I was trying this with plt.scatter:

Graph 1 enter image description here

After, I tried this using lmplot but the point size is different in relation to the first graph. I think the two graphs should be equals. Why not? The point size is different in every graph.

Graph 2 enter image description here

question from:https://stackoverflow.com/questions/65924997/why-the-point-size-using-sns-lmplot-is-different-when-i-used-plt-scatter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your question is no so much descriptive but i guess you want to control the size of the marker. Here is more documentation

Here is the start point for you. A numeric variable can also be assigned to size to apply a semantic mapping to the areas of the points:

import seaborn as sns

tips = sns.load_dataset("tips")
sns.scatterplot(data=tips, x="total_bill", y="tip", hue="size", size="size")

enter image description here

For seaborn scatterplot:

df = sns.load_dataset("anscombe")
sp = sns.scatterplot(x="x", y="y", hue="dataset", data=df)

enter image description here

And to change the size of the points you use the s parameter.

sp = sns.scatterplot(x="x", y="y", hue="dataset", data=df, s=100)

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...