【发布时间】:2021-01-01 18:22:23
【问题描述】:
matplotlib.pyplot.scatter 有一个facecolors=None 参数,该参数将使数据点标记看起来内部是空心的。我怎样才能获得与pandas.DataFrame.plot.scatter() 相同的外观?
【问题讨论】:
标签: python pandas matplotlib data-visualization scatter-plot
matplotlib.pyplot.scatter 有一个facecolors=None 参数,该参数将使数据点标记看起来内部是空心的。我怎样才能获得与pandas.DataFrame.plot.scatter() 相同的外观?
【问题讨论】:
标签: python pandas matplotlib data-visualization scatter-plot
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')
【讨论】: