Reputation: 1682
Hi I am trying to plot two things simultaneously. I do not want them on the same plot. Following is the code for first plot:
gs1 = gridspec.GridSpec(8, 20)
gs1.update(left=0.12, right=.94, wspace=0.12)
cm = plt.cm.get_cmap('RdYlBu')
ax1 = plt.subplot(gs1[0:7:, 0:6])
ax2 = plt.subplot(gs1[0:7, 7:13], sharey = ax1)
ax3 = plt.subplot(gs1[0:7, 14:20], sharey = ax1)
ax1.set_ylim(-2750,-2650)
ax1.plot(r_array_u, sum_dist, c = 'b', marker= '>')
ax2.plot(r_array_u, sum_dist_perp1, c = 'r', marker= '>')
ax3.plot(r_array_u, sum_dist_perp2, c = 'r', marker= '>')
The second plot is run by the following code:
gs1 = gridspec.GridSpec(8, 20)
gs1.update(left=0.12, right=.94, wspace=0.12)
cm = plt.cm.get_cmap('RdYlBu')
ax1 = plt.subplot(gs1[0:7:, 0:6])
ax2 = plt.subplot(gs1[0:7, 7:13], sharey = ax1)
ax3 = plt.subplot(gs1[0:7, 14:20], sharey = ax1)
ax1.set_ylim(-2750,-2650)
ax1.plot(r_array, sum_dist5, c = 'b', marker= '>')
ax2.plot(r_array, sum_dist6, c = 'r', marker= '>')
ax3.plot(r_array, sum_dist7, c = 'r', marker= '>')
How can I plot these plots on two separate 'windows' (although I use ubuntu), in a single run of my code?
Upvotes: 1
Views: 1136
Reputation: 3865
Create a new figure before doing the plot.
plt.figure()
If you want to go back, you can do it like this:
plt.figure() # figure 1
plt.plot(stuff)
plt.figure() # figure 2
plt.scatter(more_stuff_x, more_stuff_y)
# Wait, I want to add something to the first:
plt.figure(1)
plt.scatter(new_stuff)
plt.show()
Upvotes: 2