Skip to content Skip to sidebar Skip to footer

Using Subplot_kw In Matplotlib To Create A Polar Projection In Subplots

I'm trying to create a polar projection using matplotlib.pyplot.subplots() but I get the error projection is not defined when I try to pass a dictionary to matplotlib.pyplot.subplo

Solution 1:

The docs that you linked don't actually show subplot_kw being used in that way. What they show is calling dict():

fig, axes = plt.subplots(2, 2, subplot_kw=dict(polar=True))

If you print the output of subplot_kw=dict(polar=True), you get:

{'polar': True}

Notice that polar has now become a string. subplot_kw={projection:'polar'}) does not define projection as a string, it's just a variable name that Python now has to look up (and it won't find it in this case, but it may find something else in other cases).

Post a Comment for "Using Subplot_kw In Matplotlib To Create A Polar Projection In Subplots"