python 图 鼠标 显示_在matplotlib图形窗口(带imshow)中,如何删除、隐藏或重新定义鼠标的显示位置?...

是的,你可以。但比你想象的要难。

您看到的鼠标跟踪标签是根据鼠标跟踪调用matplotlib.axes.axes.format_coord生成的。您必须创建自己的Axes类(重写format_coord以执行您希望它执行的操作),然后指示matplotlib使用它来代替默认的Axes类。

具体来说:

创建自己的Axes子类from matplotlib.axes import Axes

class MyRectilinearAxes(Axes):

name = 'MyRectilinearAxes'

def format_coord(self, x, y):

# Massage your data here -- good place for scalar multiplication

if x is None:

xs = '???'

else:

xs = self.format_xdata(x * .5)

if y is None:

ys = '???'

else:

ys = self.format_ydata(y * .5)

# Format your label here -- I transposed x and y labels

return 'x=%s y=%s' % (ys, xs)

注册Axes子类from matplotlib.projections import projection_registry

projection_registry.register(MyRectilinearAxes)

创建图形并使用自定义轴figure()

subplot(111, projection="MyRectilinearAxes")

像以前一样绘制数据im = zeros([256,256]) #just a stand-in for my real images

imshow(im)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值