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?
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.
plt.figure(3)
plt.semilogy(x,y,'ro')
# .. do other stuff
# reactivate figure 3
plt.figure(3)
plt.plot(x,z)
fig3, ax3 = plt.subplots()
ax3.semilogy(x,y)
# .. do other stuff
# plot to ax3
ax3.plot(x,z)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.