Home > Mobile >  Only the last subplot has minor gridlines
Only the last subplot has minor gridlines

Time:03-30

I would like to plot a subplot with the dataframe columns so I perform the following code:

fig, axes = plt.subplots(1, 2, figsize=(10,10), tight_layout=True)

plt.minorticks_on()
plt.grid(which='minor', linestyle='-', alpha=0.5)

ori_df.plot(x='Predicted', y='Actual', kind='scatter', ax=axes[0])
ori_df.plot(x='Predicted', y='# Difference', kind='scatter', ax=axes[1])

plt.show()

However, why does only the last plot have minor gridlines? subplots

CodePudding user response:

you need to specify each axis:

axes[0].grid(which='minor', linestyle='-', alpha=0.5)
axes[1].grid(which='minor', linestyle='-', alpha=0.5)

or:

for axis in axes:
    axis.grid(which='minor', linestyle='-', alpha=0.5)

Same for minorticks_on()

  • Related