matplotlib.pyplot.scatter
有一个facecolors=None
参数,该参数将使数据点标记的内部呈空心。如何为pandas.DataFrame.plot.scatter()
获得相同的外观?
答案 0 :(得分:1)
这是选项c
(请注意,即使'None'
中的None
也是facecolors
而不是plt
):
df.plot.scatter(x='x',y='y', c='None', edgecolors='C1')
输出:
答案 1 :(得分:1)
matplotlib
文档中很难找到,但是似乎fc
和ec
分别是facecolor
和edgecolor
的别名。pandas
绘图引擎为matplotlib
。fc
。要使用fc
,您还应该使用ec
。
fc='none'
而不指定ec
将导致空白标记。'None'
和'none'
均有效,但None
无效。
import seaborn as sns # for data
import matplotlib.pyplot as plt
# load data
penguins = sns.load_dataset("penguins", cache=False)
# set x and y
x, y = penguins["bill_length_mm"], penguins["bill_depth_mm"]
# plot
plt.scatter(x, y, fc='none', ec='g')
# penguins is a pandas dataframe
penguins[['bill_length_mm', 'bill_depth_mm']].plot.scatter('bill_depth_mm', 'bill_length_mm', ec='g', fc='none')