[英]How to get color of most recent plotted line in pandas df.plot()
我想得到我最后一个情节的颜色
ax = df.plot()
df2.plot(ax=ax)
# how to get the color of this last plot,
#the plot is a single timeseries, there is therefore a single color.
我知道如何在matplotlib.pyplot
做到这一点,对于那些感兴趣的人在这里看到,但我找不到在熊猫中做到这一点的方法。 在熊猫中有类似get_color()
东西吗?
您不能对DataFrame.plot
执行相同的操作,因为它不会像pyplot.plot
那样返回Line2D
对象的列表。 但是ax.get_lines()
将返回在轴上绘制的线条列表,以便您可以查看最后绘制的线条的颜色:
ax.get_lines()[-1].get_color()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.