1

I want to plot my all dataframess 'oran' column with using subplot.

data contains 'oran' column.

Here is my code;

fig, axes = plt.subplots(6,2, figsize=(20,20))
for ax in axes:
 for month in dftm.month_base_valor.unique():
 temp = dftm[dftm.month_base_valor.eq(month)]
 #display(temp)
 temp.oran.plot(ax=ax)
fig.tight_layout()

But this code gives me the error 'numpy.ndarray' object has no attribute 'get_figure'

I couldn't find the way to solve this problem. How can i avoid this error?

The first 5 row of the dataset

month_base_valor aylık_total valor_tarihi gunluk_total oran year
0 2017-01 11111.50 20170102 11111.37 0.00 2017
1 2017-01 11111.50 20170103 11111.66 0.00 2017
2 2017-01 11111.50 20170104 11111.97 0.00 2017
3 2017-01 11111.50 20170105 11111.09 0.01 2017
4 2017-01 11111.50 20170106 11111.74 0.01 2017
asked Feb 18, 2022 at 12:25
4
  • 1
    Are you sure the error is from somewhere in the mentioned code? Didn't you call get_figure function somewhere else? Commented Feb 18, 2022 at 12:35
  • 1
    No i didnt call the get_figure, its in ----> temp.oran.plot(ax=ax) Commented Feb 18, 2022 at 12:36
  • 1
    Please provide us with your dataframe or at least a part of it in order for us to find out what's going on. Commented Feb 18, 2022 at 13:16
  • 1
    I added first rows @AmirhosseinKiani Commented Feb 18, 2022 at 13:29

1 Answer 1

1

The problem is that axes is a 2-dimensional array (shape (6,2)).

The loop for ax in axes: ... selects 1d arrays (shape (2,)) out of it. Passing this array as ax-kwarg to temp.oran.plot(ax=ax) results in the respective error.

Using for ax in axes.flat: ... should work.

answered Feb 18, 2022 at 13:42

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.