X custom data, Y custom data, how to fill gradient color in area chart?

☆樱花仙子☆ 提交于 2019-12-11 07:50:00

问题


I have custom data on X and Y. Actually i'm using plt.fill_between to have an area chart with fixed color. I would like to have gradient color instead of fixed color.

import matplotlib.pyplot as plt
import pylab
import numpy as np
import matplotlib

x1 = ['LUG','17','18','19','22','23','24','25','26','29','30','31','AGO','2']
z = [0,0.27,0.6,0.42,-0.48,-0.53,0.41,-0.61,0.48,-0.25,1.04,1.57,1.07,1.69]

plt.subplot(4, 1, 4)
plt.fill_between(x1, z, color='yellow', alpha=0.1)
plt.fill_between( x1, z, color="yellow", alpha=0.1)
plt.plot(x1, z, color="red", alpha=0.6)
plt.axhline(y=0, linewidth=1, color='pink')
plt.xlabel('time (day)')

#legend
plt.legend(['Equity'], loc='lower left')

plt.tight_layout()
plt.show()

来源:https://stackoverflow.com/questions/57346334/x-custom-data-y-custom-data-how-to-fill-gradient-color-in-area-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!