pandas 调整散点图中的点大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34049147/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adjusting dot size in scatterplot
提问by Baron Yugovich
I am doing
我在做
ax = df.plot(x=x_col, y=y_col, style=['o', 'rx'])
but I don't like that the data points are large circles. I have thousands of datapoints, so it makes the plot ugly. Any idea how I can make the dots smaller, i.e. have them be actual points, rather than circles? Or any alternative suggestions for this sort of scatterplot?
但我不喜欢数据点是大圆圈。我有数千个数据点,所以它使情节丑陋。知道如何使点变小,即让它们成为实际的点,而不是圆圈吗?或者对这种散点图有什么替代建议?
回答by Stefan
The DataFrame.plot()
docsinclude the option to pass keyword arguments to the underlying matplotlib
plotting method. As you can see here, there's an argument s
for the dot size. So you should be able to:
该DataFrame.plot()
文档包括对关键字参数传递到下面的选项matplotlib
绘制方法。正如您在此处看到的,s
对于点的大小存在争议。所以你应该能够:
ax = df.plot(kind='scatter', x=x_col, y=y_col, style=['o', 'rx'], s=12)
This is also illustrated in the pandas
visualization docs.
这也在pandas
可视化文档中进行了说明。
回答by atomh33ls
The valid matplotlib marker stylesinclude; '.'
(point) and ','
(pixel).
在有效matplotlib标记样式包括: '.'
(点)和','
(像素)。
So an alternative could be:
所以一个替代方案可能是:
ax = df.plot(x=x_col, y=y_col, style=['.', 'rx'])