As a follow-up to my previous question, I was wondering what is the proper way of creating multiple polar contourf
subplots and add a single color bar to them. I tried this way:
import numpy as np
import matplotlib.pyplot as plt
#-- Generate Data -----------------------------------------
# Using linspace so that the endpoint of 360 is included...
azimuths = np.radians(np.linspace(0, 360, 100))
zeniths = np.arange(0, 70, 10)
r, theta = np.meshgrid(zeniths, azimuths)
values1 = np.random.random((azimuths.size, zeniths.size))
values2 = np.random.random((azimuths.size, zeniths.size))
#-- Plot... ------------------------------------------------
fig, axs = plt.subplots(1, 2, subplot_kw=dict(projection='polar'))
p1 = axs[0].contourf(theta, r, values1, 100)
p2 = axs[1].contourf(theta, r, values2, 100)
cbar = plt.colorbar(p2, ax=axs[1])
plt.show()
But the polar plot on the right is smaller than the other one:
Notice that if the colorbar
line is commented the two subplots have the same size:
How do I get them to have the same size? Also, how can I resize the color bar to be as tall as the polar circles? Thanks!