Reputation: 137
I have made the following visualization.
I am at loss to figure out how to adjust the size of the third subplot according to the other two (they are sharing the x-axis).
The properties that are given here are not helping much and the examples I found on SO also seem to be addressing cases different from mine. Can anyone please help?
Upvotes: 1
Views: 1214
Reputation: 339220
An easy method would be to add another two colorbars but make them invisible.
import matplotlib.pyplot as plt
fig, (ax,ax2,ax3) = plt.subplots(3,1, sharex=True)
ax.plot([1,3,5],[1,2,5])
ax2.plot([3,5,9],[4,2,2])
ax3.plot([5,7,12],[1,5,3])
sm = plt.cm.ScalarMappable()
sm.set_array([])
fig.colorbar(sm, ax=ax3)
# add two more colorbars, but make them invisible
fig.colorbar(sm, ax=ax2).ax.set_visible(False)
fig.colorbar(sm, ax=ax).ax.set_visible(False)
plt.subplots_adjust(right=1)
plt.show()
Upvotes: 2