0

I have a couple plots made by different programs in a way that I can't easily combine them. I have them saved as pickle files as described in this post: Store and reload matplotlib.pyplot object. Now I am trying to reload multiple plots into my program and using subplots to plot them together.

I've tried:

ax1 = pkl.load(open("plot1.pkl", "rb"))
ax2 = pkl.load(open("plot2.pkl", "rb"))
fig, axs = plt.subplots(2, 1, sharey=True)
axs[0][0] = ax1
axs[0][1] = ax2
plt.show()

However when the plots are displayed I get three plots: The two original plot and a blank subplot. What should I do to get the two plots in ax1 and ax2 to display in the subplot object?

Thank you!

Ben Rei
  • 109
  • 1
  • 3
  • 12
  • `subplots(2, 3)` specifies that you want 2 rows and 3 columns. However, if you need only two subplots, you can go with `subplots(nrows=1, ncols=2). Then you can put ax1 and ax2 into axs[0] and axs[1]. – krm Feb 02 '21 at 04:02
  • Yeah but that doesn't solve the problem of getting the plots to actually show up together. The subplot figure is empty. I updated the code example above because that is not the crucial part. – Ben Rei Feb 02 '21 at 04:04

0 Answers0