Matplotlib subplot share y1/14/2024 ![]() When you create a subplot() or axes() instance, you can pass in a keyword indicating what axes you. ![]() The other answer has code for dealing with a list of axes: axes.get_shared_x_axes(). Sharing axis limits and views sharex and sharey attribute. # 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) 1 I am plotting a sample in 16 subplots together with one value in each of the plots, like this: (example of first subplot) fig, ax plt.subplots (4, 4) ax 0, 0.scatter (CCHmetalicities,CCHXoverFe, color 'gray', s 3) row0, col0 (100s of values) ax 0,0. Either figplt.figure () ax1 plt.subplot (211) ax2 plt.subplot (212, sharex ax1) or fig, (ax1, ax2) plt.subplots (nrows2, sharexTrue) Sharing the axes after they have been created should therefore not be necessary. The usual way to share axes is to create the shared properties at creation. 240 The usual way to share axes is to create the shared properties at creation. Maybe the best way to do this is actually to use subplots With the sharex and sharey it certainly seems more effective. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |