

So this means the axis move along their x axis together.

With this, we can load the graph, then we can zoom in to a specific point, and the result would be something like: To do this, we need to add it into the axis definitions: fig = plt.figure()Īx1 = plt.subplot2grid((6,1), (0,0), rowspan=1, colspan=1)Īx2 = plt.subplot2grid((6,1), (1,0), rowspan=4, colspan=1, sharex=ax1)Īx3 = plt.subplot2grid((6,1), (5,0), rowspan=1, colspan=1, sharex=ax1)Ībove, for ax2 and ax3, we add a new parameter, called sharex, and then we're saying we want to share the x with ax1. Now, let's share the x axis between all of the axis.

_major_locator(mticker.MaxNLocator(nbins=4, prune='upper')) Sharex is maybe better thought of as "duplicate x."īefore we get to that, first we're going to prune and set the max number of ticks on the other axis like so: _major_locator(mticker.MaxNLocator(nbins=7, prune='upper'))Īnd. In this tutorial for data visualization in Matplotlib, we're going to be talking about the sharex option, which allows us to share the x axis between plots.
