imshow: labels as any arbitrary function of the image indices

后端 未结 1 1728
甜味超标
甜味超标 2021-01-23 21:05

imshow plots a matrix against its column indices (x axis) and row indices (y axis). I would like the axes labels to not be indices, but an arbitrary function of the

1条回答
  •  孤独总比滥情好
    2021-01-23 21:19

    You can do this with a combination of Locators and Formatters (doc).

    ax = gca()
    ax.imshow(rand(500,500))
    
    ax.get_xaxis().set_major_formatter(FuncFormatter(lambda x,p :"%.2f"%(x/44100)))
    ax.get_yaxis().set_major_locator(LinearLocator(7))
    ax.get_yaxis().set_major_formatter(FixedFormatter(['c', 'd', 'e', 'f', 'g', 'a', 'b']))
    draw()
    

    0 讨论(0)
提交回复
热议问题