调整散点图中的点大小

Adjusting dot size in scatterplot

我在做

ax = df.plot(x=x_col, y=y_col, style=['o', 'rx'])

但我不喜欢数据点是大圆圈。我有数以千计的数据点,所以这让情节变得丑陋。知道如何使点更小,即让它们成为实际的点,而不是圆圈吗?或者对这种散点图有任何替代建议吗?

DataFrame.plot() docs include the option to pass keyword arguments to the underlying matplotlib plotting method. As you can see here,有一个关于点大小的参数s。所以你应该能够:

ax = df.plot(kind='scatter', x=x_col, y=y_col, style=['o', 'rx'], s=12)

这在 pandas visualization docs 中也有说明。

valid matplotlib marker styles 包括; '.'(点)和 ','(像素)。

所以替代方案可以是:

ax = df.plot(x=x_col, y=y_col, style=['.', 'rx'])