This problem seems simple enough, but I can't find a pythonic way to solve it. I have several (four) subplots that are supposed to have the same xlim
and ylim
. Iterating over all subplots à la
f, axarr = plt.subplots(4)
for x in range(n):
axarr[x].set_xlim(xval1, xval2)
axarr[x].set_ylim(yval1, yval2)
isn't the nicest way of doing things, especially for 2x2 subplots – which is what I'm actually dealing with. I'm looking for something like plt.all_set_xlim(xval1, xval2)
.
Note that I don't want anything else to change (ticks and labels should be controlled separately).
EDIT: I'm using the plt.subplots(2, 2)
wrapper. Following dienzs answer, I tried plt.subplots(2, 2,sharex=True, sharey=True)
– almost right, but now the ticks are gone except for the left and bottom row.