python - 通过 ubuntu 应用程序运行的 Matplotlib 弃用警告

标签 python shell ubuntu matplotlib

我正在通过 Windows 上的 shell 运行程序并不断收到此弃用错误。这是正在运行的代码和错误消息:

代码:
类窗口:
"""
使用 Matplotlib 绘制网格世界实例的窗口
"""

def __init__(self, title):
    self.fig = None

    self.imshow_obj = None

    # Create the figure and axes
    self.fig, self.ax = plt.subplots()

    # Show the env name in the window title
    self.fig.canvas.set_window_title(title)

    # Turn off x/y axis numbering/ticks


    self.ax.set_xticks([], [])
    self.ax.set_yticks([], [])

    # Flag indicating the window was closed
    self.closed = False

    def close_handler(evt):
        self.closed = True

    self.fig.canvas.mpl_connect('close_event', close_handler)

def show_img(self, img):

错误:
/home/msaidi/gym-minigrid/gym_minigrid/window.py:31:MatplotlibDeprecationWarning:自 Matplotlib 3.2 起,不推荐按位置传递 set_xticks() 的次要参数;该参数将在以后的两个次要版本中成为仅关键字。
self.ax.set_xticks([], [])
/home/msaidi/gym-minigrid/gym_minigrid/window.py:32:MatplotlibDeprecationWarning:自 Matplotlib 3.2 起,不推荐在位置上传递 set_yticks() 的次要参数;该参数将在以后的两个次要版本中成为仅关键字。
self.ax.set_yticks([], [])

当我在 ide 中编译代码时,我没有收到任何错误。

我尝试从 self.ax.set_xticks 更改为 set_xticks 并更改为 ax.set_xticks 和 self.set_xticks 并且没有工作。

Matplotlib 版本:3.2.1
python 3
运行(ubuntu windows 应用程序)

最佳答案

您需要将刻度值和刻度标签分开。

ax.set_xticks([]) # values
ax.set_xticklabels([]) # labels

关于python - 通过 ubuntu 应用程序运行的 Matplotlib 弃用警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61412472/

相关文章:

python - Tensorflow神经网络损失没有减少

bash - 如何创建一个用固定字符串初始化的固定大小的文件?

ruby-on-rails - 缺少 `secret_token` 和 `secret_key_base` - Rails 4.2.0 with RVM

linux - 撤消 Lubuntu 安装?

Python系列算法

Python:检查单词是否拼写正确

python - 如何表示 Pandas DataFrame 中缺失的数据?

linux - 如何在接收参数的shell脚本中创建一个函数?

bash - 这个脚本如何在 Ubuntu 中工作?

ubuntu - 404 响应附加到 webapi 响应