我试图用颜色绘制一个参数随时间的变化……因此,我希望有一个连续的颜色渐变穿过所有的图,例如代表1985-2018年的浅蓝色到深蓝色。或“jet”彩色地图穿过。。这可能吗
fig, ax = plt.subplots()
ax.scatter(dfc['st'],dfc['y1985'],c='lightskyblue')
ax.scatter(dfc['st'],dfc['y1986'],c='lightskyblue')
ax.scatter(dfc['st'],dfc['y1987'],c='cornflowerblue')
ax.scatter(dfc['st'],dfc['y1988'],c='cornflowerblue')
ax.scatter(dfc['st'],dfc['y1989'],c='steelblue')
ax.scatter(dfc['st'],dfc['y1990'],c='steelblue')
ax.scatter(dfc['st'],dfc['y1991'],c='royalblue')
ax.scatter(dfc['st'],dfc['y1992'],c='royalblue')
ax.scatter(dfc['st'],dfc['y1993'],c='navy')
ax.scatter(dfc['st'],dfc['y1994'],c='navy')
ax.scatter(dfc['st'],dfc['y1995'],c='lightgreen')
ax.scatter(dfc['st'],dfc['y1996'],c='lightgreen')
ax.scatter(dfc['st'],dfc['y1997'],c='mediumseagreen')
ax.scatter(dfc['st'],dfc['y1998'],c='mediumseagreen')
ax.scatter(dfc['st'],dfc['y1999'],c='seagreen')
ax.scatter(dfc['st'],dfc['y2000'],c='seagreen')
ax.scatter(dfc['st'],dfc['y2001'],c='green')
ax.scatter(dfc['st'],dfc['y2002'],c='green')
ax.scatter(dfc['st'],dfc['y2003'],c='darkgreen')
ax.scatter(dfc['st'],dfc['y2004'],c='darkgreen')
ax.scatter(dfc['st'],dfc['y2005'],c='lightsalmon')
ax.scatter(dfc['st'],dfc['y2006'],c='lightsalmon')
ax.scatter(dfc['st'],dfc['y2007'],c='darksalmon')
ax.scatter(dfc['st'],dfc['y2008'],c='darksalmon')
ax.scatter(dfc['st'],dfc['y2009'],c='coral')
ax.scatter(dfc['st'],dfc['y2010'],c='coral')
ax.scatter(dfc['st'],dfc['y2011'],c='orangered')
ax.scatter(dfc['st'],dfc['y2012'],c='orangered')
ax.scatter(dfc['st'],dfc['y2013'],c='maroon')
ax.scatter(dfc['st'],dfc['y2014'],c='maroon')
ax.scatter(dfc['st'],dfc['y2015'],c='mediumpurple')
ax.scatter(dfc['st'],dfc['y2016'],c='mediumpurple')
ax.scatter(dfc['st'],dfc['y2017'],c='rebeccapurple')
ax.scatter(dfc['st'],dfc['y2018'],c='rebeccapurple')
谢谢你的帮助:)
如果查看this example plot,它会为颜色创建一个随机数组:
由于我对你的数据一无所知,我给你一个大致的答案:
希望这有帮助:)
套餐:
示例数据:
数据采用宽格式,对于Matplotlib,长格式更适合。为此,我们可以使用
pd.melt
:然后,我们需要用序列重新编码时间数据:
情节:
相关问题 更多 >
编程相关推荐