![]() The other answer has code for dealing with a list of axes: axes.get_shared_x_axes(). # 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). When you create a subplot() or axes() instance, you can pass in a keyword indicating what axes you. Using ax1.get_shared_x_axes().join(ax1, ax2)Ĭreates a link between the two axes, ax1 and ax2. Sharing axis limits and views sharex and sharey attribute. ![]() ![]() 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) 1 Hello, Im trying to build an orthogonal-views volume viewer in Matplotlib like this one: For this to work, I need to share the y-axis of the YZ (right) view/subplot with the x-axis of the XZ (bottom) view/subplot. To help address this, the matplotlib command includes sharex and sharey. Since both the above subplots have the same -axis limits, you can remove the redundant -axis values from the right-hand side subplot using the keyword shareyTrue fig, (ax1, ax2) plt. The usual way to share axes is to create the shared properties at creation. Figures with lots of subplots often have redundant labels. Creating a subplot will delete any pre-existing subplot that overlaps with it beyond sharing a boundary: import matplotlib.pyplot as plt plot a line, implicitly creating a subplot (111) plt.plot( 1,2,3) now create a subplot which represents the top plot of a grid with 2 rows and 1 column.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |