Skip to content

[ENH]: Syntax addition request to format subplots managed by pyplot.subplots #26944

Closed as not planned
@yaredtds

Description

@yaredtds

Problem

  • 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.

Have a nice day!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions