5

I have created a figure in one part of the code as follows:

n = arange(51)
fig3 = plt.figure()
plt.semilogy(n,a1mag,'ro')

Now, i want to add another plot to this figure at a later part of the code. Is there some way to access fig3 while plotting?

0

1 Answer 1

13

It would be recommendable to either stay completely in the pyplot state-machine or comlpetely in the object oriented API; mixing the two causes just headaches.

pyplot

plt.figure(3)
plt.semilogy(x,y,'ro')

# .. do other stuff
# reactivate figure 3
plt.figure(3)
plt.plot(x,z)

object-oriented API

fig3, ax3 = plt.subplots()
ax3.semilogy(x,y)
# .. do other stuff
# plot to ax3
ax3.plot(x,z)
Sign up to request clarification or add additional context in comments.

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.