Python Forum
How to escape OrderedDict as an argument?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to escape OrderedDict as an argument?
#1
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!
Reply
#2
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?
Mark17 likes this post
Reply
#3
That was the problem... left out the ax[]. Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  use of escape character in re.sub and find WJSwan 1 877 Feb-16-2023, 05:19 PM
Last Post: Larz60+
  Escape indentation Frankduc 11 2,982 Jan-31-2022, 02:41 PM
Last Post: Frankduc
  add Escape charcters in string GrahamL 3 1,141 Jan-20-2022, 01:15 PM
Last Post: GrahamL
  Escape Single quotation between each content tag usman 3 2,743 May-02-2021, 03:32 PM
Last Post: snippsat
  DIY Escape Room for fun StannemanPython 1 2,271 Feb-17-2021, 10:53 PM
Last Post: maurom82
  extracting second values elements only in every keys in an OrderedDict glennford49 4 2,470 Nov-12-2020, 08:22 AM
Last Post: glennford49
  AttributeError: 'collections.OrderedDict' object has no attribute 'value_counts Kristenl2784 4 7,270 Jul-17-2020, 01:50 AM
Last Post: palladium
  collections.OrderedDict Bert123456 2 1,748 Jul-09-2020, 08:51 PM
Last Post: Bert123456
  KeyError in OrderedDict rberna 1 2,085 Apr-01-2020, 04:42 AM
Last Post: perfringo
  SyntaxError: positional argument follows keyword argument syd_jat 3 5,737 Mar-03-2020, 08:34 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020