1

I am plotting some data using pylab and everything works perfect as I expect. I have 6 different graphs to plot and I can individually plot them in separate figures. But when I try to subplot() these graphs, the last one (subplot(3,2,6)) doesn't show anything.

What confuses me is that this 6th graph is drawn perfectly when put in a separate figure but not in the subplot - with identical configurations.

Any ideas what may be causing the problem ?

1
  • 1
    I am glad you sorted out your own problem, however could you add some example code so this will be more helpful for future users. Commented Apr 21, 2013 at 16:55

2 Answers 2

1

I found out that subplot() should be called before the plot(), issue resolved.

Sign up to request clarification or add additional context in comments.

Comments

1

In general, if you are working with more than one axes or writing non-interactive scripts it is better to use the OO interface, rather than the state-machine (MATLAB-like) interface. You could do this as:

fig, sub_lst = plt.subplots(3, 2)
sub_lst = sub_lst.ravel() # flatten list
for sub_p in sub_lst:
    sub_p.plot(...)
    # what ever other plotting commands you use

Note that the plotting functions are member functions of the axes objects returned by subplots.

See How can I attach a pyplot function to a figure instance? for a longer discussion of the OO vs state-machine interfaces

Comments

Your Answer

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.