Python Forum

Full Version: How to escape OrderedDict as an argument?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here's some code:
import matplotlib.pyplot as plt
import collections

markets = ['ES', 'GC', 'CL', 'EC', 'US']

axL_index = collections.OrderedDict()
axR_index = collections.OrderedDict()
axL_index[1] = 0; axL_index[2] = 0; axL_index[3] = 1
axL_index[4] = 1; axL_index[5] = 2; axL_index[6] = 2
axR_index[1] = 0; axR_index[2] = 1; axR_index[3] = 0
axR_index[4] = 1; axR_index[5] = 0; axR_index[6] = 1

fig, ax = plt.subplots(3,2,sharex=True)
if len(markets) % 2 != 0:
    fig.delaxes(axL_index[next(reversed(axL_index))],axR_index[next(reversed(axR_index))])
The exception is:

TypeError: delaxes() takes 2 positional arguments but 3 were given

As an object, I've read OrderedDict counts as one argument passed to delaxes. How can I get around this constraint? Thanks!
The method is defined to take a single argument of type Axes (see https://matplotlib.org/3.3.3/_modules/ma...re.delaxes). Why are you trying to pass two arguments, neither of which are of type Axes?
That was the problem... left out the ax[]. Thank you!