gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 12:05:47 26 4
gpt4 key购买 nike

我正在通过 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/

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