Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib deprecation warning running through ubuntu application

I'm running a program through shell on windows and keep getting this deprecation error. Here is the code being ran and the error message:

Code: class Window: """ Window to draw a gridworld instance using 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):

Error: /home/msaidi/gym-minigrid/gym_minigrid/window.py:31: MatplotlibDeprecationWarning: Passing the minor parameter of set_xticks() positionally is deprecated since Matplotlib 3.2; the parameter will become keyword-only two minor releases later. self.ax.set_xticks([], []) /home/msaidi/gym-minigrid/gym_minigrid/window.py:32: MatplotlibDeprecationWarning: Passing the minor parameter of set_yticks() positionally is deprecated since Matplotlib 3.2; the parameter will become keyword-only two minor releases later. self.ax.set_yticks([], [])

When I compile the code in the ide I don't get any errors.

I tried changing from self.ax.set_xticks to set_xticks and to ax.set_xticks and self.set_xticks and didn't work.

Matplotlib version: 3.2.1 python3 running through (ubuntu windows application)

like image 965
msaidi Avatar asked Dec 18 '22 13:12

msaidi


2 Answers

You need to separate tick values and tick labels.

ax.set_xticks([]) # values
ax.set_xticklabels([]) # labels
like image 185
Naomi Fridman Avatar answered Dec 20 '22 04:12

Naomi Fridman


Just change it to:

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

The error says that the second parameter cannot be given positionally, meaning that you need to explicitly give the parameter name minor=False for the second parameter or remove the second parameter in your case.

like image 27
Noe Avatar answered Dec 20 '22 03:12

Noe