5/21/2023 0 Comments Sharex tutorialax11 means the second row (index 1) and the second element from that row (index 1). axs00 means first row (index 0) and the first plot from that row (index 0). The other answer has code for dealing with a list of axes: axes.get_shared_x_axes(). How to access subplots in Matplotlib Accessing subplots is similar to accessing elements from a 2D array. # ax2.autoscale() # call autoscale if needed In 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. 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: ![]() Sharing the axes after they have been created should therefore not be necessary. Or fig, (ax1, ax2) = plt.subplots(nrows=2, sharex=True) The usual way to share axes is to create the shared properties at creation.
0 Comments
Leave a Reply. |