标签: python matplotlib
我要删除在颜色栏右边带有数字的(勾号)轴。我将python使用matplotlib如下:
f = plt.figure() ax = f.add_subplot(1,1,1) i = ax.imshow(mat, cmap= 'gray') cbar = f.colorbar(i)
答案 0 :(得分:1)
如果您只想删除刻度线,但保留刻度线标签,则可以将刻度线的大小设置为0,如下所示:
f = plt.figure() ax = f.add_subplot(1,1,1) mat = np.arange(100).reshape((10, 10)) i = ax.imshow(mat, cmap= 'viridis') cbar = f.colorbar(i) cbar.ax.tick_params(size=0)
如果要同时删除刻度线和标签,则可以通过传递空白列表来使用set_ticks([])。
set_ticks([])
cbar.set_ticks([])