gpt4 book ai didi

python - 在 matplotlib 图上禁用工具栏上的像素值

转载 作者:太空宇宙 更新时间:2023-11-03 15:21:30 26 4
gpt4 key购买 nike

继续阅读herehere ,他们使用 format_coord 禁用坐标或从工具栏更改格式。使用 axe.format_coord = lambda x, y: '' 如链接问题中所示,删除了坐标,这很好。但是,我还想禁用像素值:enter image description here

然后我尝试使用

axe.format_coord = lambda x, y,z:''

但是出现了错误:

    s = event.inaxes.format_coord(event.xdata, event.ydata)
TypeError: <lambda>() takes exactly 3 arguments (2 given)

请帮我解决这个问题。

最佳答案

为了抑制图窗窗口状态栏中的任何输出,可以用 lambda 替换图窗工具栏的消息方法(NavigationToolbar2.set_message)返回空字符串的函数:

fig.canvas.toolbar.set_message = lambda x: ""

完整示例:

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()

ax.imshow(np.random.rand(5,5))
fig.canvas.toolbar.set_message = lambda x: ""

plt.show()

关于python - 在 matplotlib 图上禁用工具栏上的像素值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43501370/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com