目的:从彩色图变黑白图图1图2图3图4
思路:
我到要出图这步骤时,是pandas的dataframe。
如果是要出曲线图,则直接在df.plot里改参数style即可。就能出图4。
fig = df.plot(kind='line', color='k', style=['--', ':', '-']
fig.savefig(r'xx/xxx/xx/xxx.jpg')
其中线性共有这些选项: '-', '--', '-.', ':', 'None', ' ', '', 'solid', 'dashed', 'dashdot', 'dotted'
其实总共就4种,'solid', 'dashed', 'dashdot', 'dotted' 就是 '-', '--', '-.', ':'。
如果你要用4中以上,资料显示可以调整黑白程度,就可以无数种。
fix,ax = plt.subplots()
ax.set_prop_cycle(
cycler(color=[(.8,.8,.8), (.5,.5,.5), (.2,.2,.2)]) *
cycler(linestyle=['-', '--', '-.'])
) #repeats after 9 columns
df.plot(ax=ax)