0

I am using pythons plt.subplot function to generate multiple plots. I use a loop over the axis, to generate the plots with specific data and to set the axis properties. Below, i have put a simplified example of the code workflow (figuratively) I am speaking of.

fig,axis =  plt.subplots(3,2) 

loop over rows:
  loop over columns:
      axis[row][col].plt(plot the data)
      axis[row][col].grid()
      axis[row][col].legend()
      axis[row][col].set_xlabel(...)
      etc...

so what came to my mind was, that perhaps i could set the common setup properties of the axis in a more general manner which also enhances the readability of the code. Now I know that some of the properties can be set via plt.rcParams and others via plt.setp but i thoughed a more elegant way would be the following approach to access all the axis elements in an numpy array manner

axis[:][:].set_xlabel(...)

However, i receive the following error massage: "'numpy.ndarray' object has no attribute 'set_xlabel'"

Is there any elegant way to apply my solution or something similar in a correct way?

Cheers

eSi
  • 3
  • 1

1 Answers1

0

There isn't. Legends and labels are specific to the subplot. Grid you can set with rcparams globally.

If you are setting the same labels for all subplots, you might consider just setting it once like in this question

Ruli
  • 2,592
  • 12
  • 30
  • 40
Darina
  • 1,488
  • 8
  • 17