I built a set of pie charts with some help. Insert an image into a slice of a pie chart. My charts look great, now I need to put all 6 of them in a 2x3 shape with common marks on the common x and y axis. To start, I look at the subtitles and thought that I could make it work. I downloaded a few examples and started trying a few things.
f, (a) = (plt.subplots(nrows=1, ncols=1, sharex=True, sharey=True))
gives:
class 'matplotlib.figure.Figure'
class 'matplotlib.axes._subplots.AxesSubplot'
a
f, (a) = (plt.subplots(nrows=1, ncols=1, sharex=True, sharey=True, squeeze=False, subplot_kw=None, gridspec_kw=None)) print(type(f),'\n',type(a),'\n')
returns:
class 'matplotlib.figure.Figure'
class 'numpy.ndarray'
When I do this:
f, (a,b) = (plt.subplots(nrows=2, ncols=1, sharex=True, sharey=True, squeeze=False, subplot_kw=None, gridspec_kw=None)) print(type(f),'\n',type(a),'\n',type(b))
I get similar results, however if nrows = 1 and ncols = 2, I get an error message:
f, (a,b) = (plt.subplots(nrows=1, ncols=2, sharex=True, sharey=True, squeeze=False, subplot_kw=None, gridspec_kw=None)) print(type(f),'\n',type(a),'\n',type(b))
ValueError: not enough values ββto unpack (expected 2, received 1)
but again:
f, (a , b) = ( plt.subplots(nrows=1, ncols=2, sharex=True, sharey=True))
gives class 'matplotlib.figure.Figure'
class 'matplotlib.axes._subplots.AxesSubplot'
class 'matplotlib.axes._subplots.AxesSubplot'
Why is it either an array or an axis, and also why is there no work of 2X1 and 1X2? I want from heaven, I could better understand the documentation. Thanks.