如何自定义python DataFrame散点图颜色?

How to customize python DataFrame scatter plot color?

我使用下面的 python 代码绘制了一个图表(附后)。问题是分配的颜色很难让人们区分每个数据点之间的差异。我想自定义色标。有人能帮忙吗?非常感谢!

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
x=[1,2,3,4,5,1,2,3,4,5]
y=[5,4,3,2,1,1,2,3,4,5]
z=[0.1,0.2,-0.1,0.3,0.05,0.1,-0.1,-0.5,0.25,-0.05]
df=pd.DataFrame({'x':x,'y':y,'z':z})
df.plot.scatter(x='x',y='y',c='z')

colormap 参数传递给 df.plot(),例如

df.plot.scatter(x='x',y='y',c='z', colormap='plasma')

来自 pandas.DataFrame.plot 的文档:

colormap : str or matplotlib colormap object, default None

Colormap to select colors from. If string, load colormap with that name from matplotlib.

您可以在 colormaps_reference.

中查看 matplotlib 颜色图(正如我在上面使用的)