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
{{ message }}
Repository navigation
[ENH]: Syntax addition request to format subplots managed by pyplot.subplots #26944
Formating graphs managed by pyplot.subplots needs a lot of redundant typing or iterating on each subplots, and I think it can be done as follows.
*for example
import matplotlib.pyplot as plot
fig, ax = plt.subplots(2,2, figsize=(8,8))
ax[0,0].plot(x1,y1, label='x1,y1')
ax[0,1].plot(x2,y2, label='x2,y2')
ax[1,0].plot(x3,y3, label='x3,y3')
ax[1,1].plot(x4,y4, label='x4,y4')
Available syntax to add grid, label, legend, etc to each plots
method-1 looping
[ax[i,j].grid(which='both') for i in range(2) for j in range(2)]
method-2 add grid, label, etc to each plots step by step in hardway
ax[0,0].grid(which='both')
ax[0,1].grid(which='both')
ax[1,0].grid(which='both')
ax[1,1].grid(which='both')
Feature Requested___
ax[0:2,0].grid(which='both') # to set for first column
ax[:,:].grid(which='both') # to set grid for all
ax.grid(which='both') # to set grid for all
Proposed solution
I would like to propose these way of syntax to simplify formating multiple subplots
Feature Requested
ax[0:2,0].grid(which='both') # to set for first column
ax[:,:].grid(which='both') # to set grid for all
ax.grid(which='both') # to set grid for all
thanks a lot and sorry if I do recommend this with limited understanding of your library. I request the above because I like it and want it to be better.
Currently the return value of subplots is a plain numpy array, so we can't do anything about the methods available on that. But there is a proposal to create our own AxesArray, which would make this sort of thing possible. See #25937.
Activity
rcomer commentedon Sep 28, 2023
Currently the return value of
subplotsis a plain numpy array, so we can't do anything about the methods available on that. But there is a proposal to create our ownAxesArray, which would make this sort of thing possible. See #25937.tacaswell commentedon Sep 28, 2023
Thank you for the suggestion @yaredtds .
I am going to close is in favor of tracking the work in #25937 as the third selling point of that proposal is "add our own functionality".