[英]plotting two DataFrame columns with different colors in python
I have a DataFrame in pandas and I'm plotting two columns out in a line graph using matplotlib
. 我在pandas中有一个DataFrame,并且正在使用
matplotlib
在折线图中绘制出两列。 However, I can't figure out how to change the individual color of each line. 但是,我不知道如何更改每行的颜色。 I can only change both or none.
我只能更改两者或全部都不更改。 Using .plot() I can only change both eg.
使用.plot()我只能更改两个。
c='red'
but I want different colors for each line. c='red'
但我希望每行使用不同的颜色。
To plot 2 columns of dataframe with colors 'green' and 'brown', use the following code: 要绘制两列具有“绿色”和“棕色”颜色的数据框,请使用以下代码:
df[['Close 30 Day MA', 'Close']].plot(figsize(16,6), color=['green', 'brown'])
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.