plt.imshow()自定义滴答集Y值[Python]

时间:2018-03-22 11:23:32

标签: python matplotlib imshow

我需要在马赛克上标记某些区域。我已经绘制了水平线,但希望能够设置它们旁边的值的刻度值。类似'0.1,0.2等'

我添加了下图的示例。

fig = plt.figure(figsize=(2,20))
plt.imshow(cube1_img_rot)
plt.imshow(cube2_img_rot, extent=[-19,1928,-24537, -22591])
plt.imshow(cube3_img_rot, extent=[-19,1928,-9352, -7476])

for i in range(len(mu_pix)):
    plt.axhline(mu_pix[i])
plt.savefig('foo.pdf', bbox_inches='tight', dpi=1000)

enter image description here

1 个答案:

答案 0 :(得分:0)

这很有效!

ax.set_yticks((                 1559.43068618,   1175.83793458,    522.94553171, -422.02772895,
                                -1696.91470316,  -3364.08381994,  -5532.01302058, -8414.16763989,
                                -12558.01658595, -23564.41909972,      0.        ))
labels = ax.set_yticklabels((0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1))