Collapse the vertical spacing between two or more subplots.
Useful for a multi-panel plot where most subplots should have space between them but several adjacent ones should not (i.e., appear as a single plot.) This function will remove all the vertical space between the subplots listed in combine and redistribute the space between all of the subplots in both combine and others in proportion to their current size, so that the relative size of the subplots does not change.
Parameters: | combine : list
|
---|---|
Other Parameters: | |
others : list
leave_axis : bool
|
Notes
This function can be fairly fragile and should only be used for fairly simple layouts, e.g., a one-column multi-row plot stack.
This may require some clean-up of the y axis labels, as they are likely to overlap.
Examples
>>> import spacepy.plot.utils
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> #Make three stacked subplots
>>> ax0 = fig.add_subplot(311)
>>> ax1 = fig.add_subplot(312)
>>> ax2 = fig.add_subplot(313)
>>> ax0.plot([1, 2, 3], [1, 2, 1]) #just make some lines
[<matplotlib.lines.Line2D object at 0x0000000>]
>>> ax1.plot([1, 2, 3], [1, 2, 1])
[<matplotlib.lines.Line2D object at 0x0000000>]
>>> ax2.plot([1, 2, 3], [1, 2, 1])
[<matplotlib.lines.Line2D object at 0x0000000>]
>>> #Collapse space between top two plots, leave bottom one alone
>>> spacepy.plot.utils.collapse_vertical([ax0, ax1], [ax2])