You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sharing axes is a really convenient feature of matplotlib. It would be handy if this was enabled in facets. It's not necessarily trivial, but I think it is possible to enable axes sharing on existing axes.
Background
Maybe there are some properties of the axes that might be missing, but simply automatically making inner ticklabels invisible, and sharing tick positions and axes limits would go a long way. In doing some searching, I found this StackOverflow question / answer, which is helpful for sharing axes limits.
The following is a modified version of the first example in the README (note this works!):
rows, cols=2, 3fig, axes=facets(rows, cols, width=8., aspect=0.6,
internal_pad=0.2, top_pad=0.5,
bottom_pad=0.5, left_pad=0.5,
right_pad=0.5)
x=np.linspace(0., 6.*np.pi)
y=np.sin(x)
# Share ticks and limits of all x and y axes# Make inner ticklabels invisible# This could all be done in the facets functionax_ref=axes[0]
axes=np.reshape(axes, (rows, cols))
foraxinaxes.flatten():
ax.xaxis.major=ax_ref.xaxis.majorax.xaxis.minor=ax_ref.xaxis.minorax.yaxis.major=ax_ref.yaxis.majorax.yaxis.minor=ax_ref.yaxis.minorax.get_shared_x_axes().join(ax_ref, ax)
ax.get_shared_y_axes().join(ax_ref, ax)
foraxinaxes[:-1, :].flatten():
ax.xaxis.set_tick_params(which='both',
labelbottom=False, labeltop=False)
foraxinaxes[:, 1:].flatten():
ax.yaxis.set_tick_params(which='both',
labelbottom=False, labeltop=False)
axes=axes.flatten()
# Besides calling facets, this is all the user would need to seeforaxinaxes:
ax.plot(x, y)
axes[0].set_ylim(-2, 2)
axes[0].set_yticks(np.arange(-2, 2.1))
axes[0].set_xticks(np.arange(0., 18.1, 6.))
axes[0].set_xlim([0, 30])
Controls sharing of properties among x (sharex) or y (sharey) axes:
True or ‘all’: x- or y-axis will be shared among all subplots.
False or ‘none’: each subplot x- or y-axis will be independent.
‘row’: each subplot row will share an x- or y-axis.
‘col’: each subplot column will share an x- or y-axis.
When subplots have a shared x-axis along a column, only the x tick labels of the bottom subplot are visible. Similarly, when subplots have a shared y-axis along a row, only the y tick labels of the first column subplot are visible.
It would be good to support all of those options from facets via sharex and sharey keyword arguments. (I think the example above would be accomplished through sharex='all' and sharey='all').
The text was updated successfully, but these errors were encountered:
AxesGrid only supports a share_all argument, which one can either set to True or False. It would be nice to enable the other share modes. In order to enable that, we would need a way to toggle axes sharing after Axes objects were created (which is discussed above).
Sharing axes is a really convenient feature of
matplotlib
. It would be handy if this was enabled infacets
. It's not necessarily trivial, but I think it is possible to enable axes sharing on existing axes.Background
Maybe there are some properties of the axes that might be missing, but simply automatically making inner ticklabels invisible, and sharing tick positions and axes limits would go a long way. In doing some searching, I found this StackOverflow question / answer, which is helpful for sharing axes limits.
Then in doing some reading of the
matplotlib
source code, namely the following lines: https://github.com/matplotlib/matplotlib/blob/a8ae66ea275b402e3461d69b19d049fc94a34b68/lib/matplotlib/figure.py#L1214-L1226, it seems it shouldn't be too hard to share ticks across axes while keeping some ticklabels visible and others invisible.Proof of concept
The following is a modified version of the first example in the README (note this works!):
Further considerations
matplotlib
has several options for sharing axes in thematplotlib.pyplot.subplots
command:It would be good to support all of those options from
facets
viasharex
andsharey
keyword arguments. (I think the example above would be accomplished throughsharex='all'
andsharey='all'
).The text was updated successfully, but these errors were encountered: