【发布时间】:2021-03-15 01:33:52
【问题描述】:
您好,我想继续我已经在这里提出的问题 Create vertical stacked bar chart referenced to y values (lithology/stratigraphic column)
问题是如何在我的 pcolor 上制作多个影线,这是图片
我想用“x”图案制作白色的 pcolor,用“+”制作红色的 pcolor。
有什么办法吗?提前谢谢你
lithcode = {'ABT': 1, 'AT': 2, 'GD': 3, 'BAT': 4, 'BTT': 5, 'TT': 6, 'NC': 7, 'MV':8, 'MS':9, 'GW':10}
colors = ['darkred', 'crimson', 'red', 'peru', 'lightsalmon', 'lightpink', 'white', 'oldlace',
'thistle', 'lightgray']
hatch=['','+','','','','','x','','','']
cmap = ListedColormap(colors)
Zb=litho['litho'].map(lithcode).to_numpy().reshape(1, -1)
nonan=np.count_nonzero(Zb[np.logical_not(np.isnan(Zb))])
Za=litho['litho'][:nonan].map(lithcode).to_numpy().reshape(1, -1)
X=litho['elev litho'][:nonan]
cl.pcolor(X, [0, 1], Za, cmap=cmap, vmin=1, vmax=len(colors))
# ax.set_yticks(data['md litho']) optionally set the y-ticks to indicate the row borders
hands = [Patch(color=col, label=k) for k, col in zip(lithcode.keys(), colors)]
cl.legend(handles=hands, loc=(1.01, 0), ncol=2, fontsize=8)
【问题讨论】:
标签: python numpy matplotlib plot colormap