If you want the fifth plot to take up the whole bottom row rather than having a blank 6th plot there you can use more advanced options like idspec described in the gridspec documentation. #now the fifth plot shouldn't clobber one of the others: To do this, FITSFigure should be called with the figure argument. #probably easiest to add a third row of plots (3,2) at this stage:į, ((ax1, ax2), (ax3, ax4),(ax5,a圆)) = plt.subplots(3, 2, sharex=True, sharey=True, facecolor='red', \ However, APLpy can be used to place a subplot in an existing matplotlib figure instance. There are various ways to work around this, but one of the simpler solutions is just to give yourself a bigger subplot grid by using a third row of plots-using a (3,2) geometry as in my example below: %pylab inline You are starting off by specifying a (2,2) geometry which is 2 rows and 2 columns, so naturally adding a 5th plot by conventional means can cause some issues. I think your intuition that you should change the geometry of the plot layout is correct. More generally what is going on with the **kwargs with subplot? If anyone can help me work out how to start using those, that would also be very handy. Do I need to change the geometry? If so, how? Or is it just a position thing? Then the new subplot overlaps with the fourth one, when I want it positioned below obviously. If I do this: x = np.linspace(0, 2 * np.pi, 400)į, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True, sharey=True, facecolor='red', \ĭpi = 100, edgecolor = 'red', linewidth = 5.0, frameon = True)Īx1.set_title('Sharing x per column, y per row')Īx3.scatter(x, 2 * y ** 2 - 1, color='r')Īnd then I want to add another subplot below: f.add_subplot(3, 2, 5) how can I change the geometry to accomodate another subplot. So for example if I create a figure with a 2*2 grid of subplots, how can I add a 5th or 6th. Creating multiple subplots in Matplotlib is a fairly simple task, as we outlined in this tutorial using subplots(). I am having difficulty understanding how to add subplots when the grid shape already exists. I'm trying to get to grips with matplotlib.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |