Using matplotlib, is it possible to set properties for all subplots on a figure at once? Using matplotlib, is it possible to set properties for all subplots on a figure at once? numpy numpy

Using matplotlib, is it possible to set properties for all subplots on a figure at once?


If your subplots are actually sharing an axis/some axes, you may be interested in specifying the sharex=True and/or sharey=True kwargs to subplots.

See John Hunter explaining more in this video. It can give your graph a much cleaner look and reduce code repetition.


I would suggest using a for loop:

for grph in [graphA, graphB]:    grph.#edit features here

You can also structure the for loop differently depending on how you want to do this, e.g.

graphAry = [graphA, graphB]for ind in range(len(graphAry)):    grph = graphAry[ind]    grph.plot(listItems1, someList[ind])#etc

The nice thing about subplots is that you can use a for loop to plot them too!

for ind in range(6):    ax = subplot(6,1,ind)    #do all your plotting code once!

You'll have to think about how to organize the data you want to plot to make use of the indexing. Make sense?

Whenever I do multiple subplots I think about how to use a for loop for them.