Question

I recently found the function subplots, which seems to be a more elegant way of setting up multiple subplots than subplot. However, I don't seem to be able to be able to change the properties of the axes for each subplot.

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as npx = np.linspace(0, 20, 100)

fig, axes = plt.subplots(nrows=2)

for i in range(10):
    axes[0].plot(x, i * (x - 10)**2)
    plt.ylabel('plot 1')

for i in range(10):
    axes[1].plot(x, i * np.cos(x))
    plt.ylabel('plot 2')

plt.show()

Only the ylabel for the last plot is shown. The same happens for xlabel, xlim and ylim.

I realise that the point of using subplots is to create common layouts of subplots, but if sharex and sharey are set to false, then shouldn't I be able to change some parameters?

One solution would be to use the subplot function instead, but do I need to do this?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top