msa*_*idi 4 python shell ubuntu matplotlib
我正在通过 Windows 上的 shell 运行程序,并不断收到此弃用错误。这是正在运行的代码和错误消息:
代码:class Window: """ Window 使用 Matplotlib """ 绘制 gridworld 实例
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):
Run Code Online (Sandbox Code Playgroud)
错误:/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 python3 跑通(ubuntu windows 应用)
您需要将刻度值和刻度标签分开。
ax.set_xticks([]) # values
ax.set_xticklabels([]) # labels
Run Code Online (Sandbox Code Playgroud)
只需将其更改为:
self.ax.set_xticks([])
self.ax.set_yticks([])
Run Code Online (Sandbox Code Playgroud)
该错误表明无法按位置给出第二个参数,这意味着您需要显式为第二个参数指定参数名称minor=False,或者在您的情况下删除第二个参数。
| 归档时间: |
|
| 查看次数: |
3484 次 |
| 最近记录: |