![]() ![]() The other answer has code for dealing with a list of axes: axes.get_shared_x_axes(). a certain amount of padding around the outside of the subplots and spacing between subplots. # ax2.autoscale() # call autoscale if needed AxesSubplot object at 0x7f5893019b50>, contrast to the sharing at creation time, you will have to set the xticklabels off manually for one of the axes (in case that is wanted). Using ax1.get_shared_x_axes().join(ax1, ax2)Ĭreates a link between the two axes, ax1 and ax2. The outline of matplotlib axes are controlled by three things: The axes bounding box within the figure (controlled by a subplot specification or a specific extent such as fig. However if for any reason, you need to share axes after they have been created (actually, using a different library which creates some subplots, like here might be a reason), there would still be a solution: Note to anyone wondering: the 0.3 is in units of inches I'm pretty sure. hspace is the vertical gap between subplots (most probably in units of the subplot-height). plt.subplotsadjust (top 0.99, bottom0.01, hspace1.5, wspace0.4) with some very extreme values. ![]() You need to define xticks properly so that the grid lines cross your data points (the dots) example below: import matplotlib.pyplot as plt fig, ax plt.subplots () numberofruns range (1,10) use your actual numberofruns ax.setxticks (numberofruns, minorFalse) ax. You need to ommit fig.tightlayout () and instead use subplotsadjust. fig,ax plt.subplots (rows,cols, figsize 24,12) or you may keep the square figure size but put more margin around the subplots. So, this works for me to increase the vertical separation between two subplots: plt.subplotsadjust(hspace0.3). The grid lines cross the xticks (or yticks). Sharing the axes after they have been created should therefore not be necessary. You may either shrink the figure size in vertical direction, e.g. Or fig, (ax1, ax2) = plt.subplots(nrows=2, sharex=True) Not sure what would be the best way to expose this. Of course, this needs some knowledge of matplotlib internals and will be difficult for normal users. In principle, you can change 'ncol' within a legend by manually rearranging these offsetboxes. The usual way to share axes is to create the shared properties at creation. Legend in matplotlib is a collection of OffsetBox. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |