I have 2 datasets, one representing Rootzone (mm) and other representing Tree cover (%). I am able to plot these datasets side by side (as shown below). The code used was:
fig = plt.subplots(figsize = (16,7))
ax = [
plt.subplot(121),
plt.subplot(122)]
classified_data.boxplot(grid=False, rot=90, fontsize=10, ax = ax[0])
classified_treecover.boxplot(grid=False, rot=90, fontsize=10, ax = ax[1])
ax[0].set_ylabel('Rootzone Storage Capacity (mm)', fontsize = '12')
ax[1].set_ylabel('Tree Cover (%)', fontsize = '12')
ax[0].set_title('Rootzone Storage Capacity (mm)')
ax[1].set_title('Tree Cover (%)')
But I want to have them in the same plot with both Rootzone (on the left-hand y-axis) and Tree cover (on the right-hand y-axis) as their range is different (using something like twinx()
). But I want them to be stacked together for a single class on the x-axis (something like as shown below with a twin y-axis for the tree cover).
Can someone guide me as to how this can be achieved with my code??