小编Mis*_*iko的帖子

根据python中的条件绘制多色线条

我有一个包含三列和一个日期时间索引的pandas数据帧

date        px_last  200dma     50dma           
2014-12-24  2081.88 1953.16760  2019.2726
2014-12-26  2088.77 1954.37975  2023.7982
2014-12-29  2090.57 1955.62695  2028.3544
2014-12-30  2080.35 1956.73455  2032.2262
2014-12-31  2058.90 1957.66780  2035.3240
Run Code Online (Sandbox Code Playgroud)

我想制作一个'px_last'列的时间序列图,如果在给定日50dma高于200dma值,则为绿色,如果50dma值低于200dma值,则为红色.我看过这个例子,但似乎无法使其适用于我的案例 http://matplotlib.org/examples/pylab_examples/multicolored_line.html

python plot matplotlib pandas

7
推荐指数
2
解决办法
5825
查看次数

标签 统计

matplotlib ×1

pandas ×1

plot ×1

python ×1