plot.subplot ---> 'Figure' object has no attribute 'plot'

lmblanes

I am trying to use subplots similar to what is being shown here:

http://matplotlib.org/examples/pylab_examples/subplots_demo.html

axarr = plt.subplots(len(column_list), sharex=True)
subp_num = 0
for j in column_list:
     axarr[subp_num].plot(df.values[2:,j])
     subp_num = subp_num + 1

then I get this error:

axarr[subp_num].plot(df.values[2:,j])
AttributeError: 'Figure' object has no attribute 'plot'

Any hint on what am I doing wrong? Thanks

jonrsharpe

You have one obvious problem: all of the examples in the link you provide look like

f, axarr = plt.subplots(...)

where the f is the Figure you are subsequently treating as if it had a plot attribute. If you are working with an arbitrary number of subplots, you could do:

axarr = plt.subplots(...)
f, axarr = axarr[0], axarr[1:]

Also, you are using a while loop with an incrementing index, which is clumsy and prone to error; just use a for loop:

for j, ax in zip(column_list, axarr):
    ax.plot(df.values[2:, j])

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Plot figure problems with python and matplotlib

From Dev

multiple plot in one figure in Python

From Dev

Alignment of the Legend in Matlab Plot Figure

From Dev

Plot a figure and exit but leave figure window open

From Dev

Plot two figures on the same figure using subplot

From Dev

'numpy.float64' object has no attribute 'plot'

From Dev

In matlab, plot a heatmap and a line plot on the same figure

From Dev

Pylab - 'module' object has no attribute 'Figure'

From Dev

Axes from plt.subplots() is a "numpy.ndarray" object and has no attribute "plot"

From Dev

AttributeError: 'Figure' object has no attribute 'plot'

From Dev

Remove the extra plot in the matplotlib subplot

From Dev

Plotly AttributeError: 'Figure' object has no attribute 'update_layout'

From Dev

mismatch between legend/figure in plot

From Dev

Plot MINST dataset images returns AttributeError: 'dict' object has no attribute 'train'

From Dev

Matplotlib: using a figure object to initialize a plot

From Dev

Plot on the same figure in Matlab

From Dev

Multiple plot in the same figure

From Dev

how to plot the figure as improfile shows

From Dev

Plot a figure and exit but leave figure window open

From Dev

Plot two figures on the same figure using subplot

From Dev

In matlab, plot a heatmap and a line plot on the same figure

From Dev

AttributeError: 'numpy.ndarray' object has no attribute 'plot'

From Dev

Plot trace of figure

From Dev

Matlab, set font in figure plot

From Dev

python plot: object has no attribute 'set_xlable'

From Dev

Plot subplot axes in separate figure in matplotlib

From Dev

dict_keys object has no attribute plot while using nltk

From Dev

Python Plot- Multiple the data in plot figure

From Dev

AttributeError: 'dict' object has no attribute 'plot'

Related Related

  1. 1

    Plot figure problems with python and matplotlib

  2. 2

    multiple plot in one figure in Python

  3. 3

    Alignment of the Legend in Matlab Plot Figure

  4. 4

    Plot a figure and exit but leave figure window open

  5. 5

    Plot two figures on the same figure using subplot

  6. 6

    'numpy.float64' object has no attribute 'plot'

  7. 7

    In matlab, plot a heatmap and a line plot on the same figure

  8. 8

    Pylab - 'module' object has no attribute 'Figure'

  9. 9

    Axes from plt.subplots() is a "numpy.ndarray" object and has no attribute "plot"

  10. 10

    AttributeError: 'Figure' object has no attribute 'plot'

  11. 11

    Remove the extra plot in the matplotlib subplot

  12. 12

    Plotly AttributeError: 'Figure' object has no attribute 'update_layout'

  13. 13

    mismatch between legend/figure in plot

  14. 14

    Plot MINST dataset images returns AttributeError: 'dict' object has no attribute 'train'

  15. 15

    Matplotlib: using a figure object to initialize a plot

  16. 16

    Plot on the same figure in Matlab

  17. 17

    Multiple plot in the same figure

  18. 18

    how to plot the figure as improfile shows

  19. 19

    Plot a figure and exit but leave figure window open

  20. 20

    Plot two figures on the same figure using subplot

  21. 21

    In matlab, plot a heatmap and a line plot on the same figure

  22. 22

    AttributeError: 'numpy.ndarray' object has no attribute 'plot'

  23. 23

    Plot trace of figure

  24. 24

    Matlab, set font in figure plot

  25. 25

    python plot: object has no attribute 'set_xlable'

  26. 26

    Plot subplot axes in separate figure in matplotlib

  27. 27

    dict_keys object has no attribute plot while using nltk

  28. 28

    Python Plot- Multiple the data in plot figure

  29. 29

    AttributeError: 'dict' object has no attribute 'plot'

HotTag

Archive