回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在使用<code>quadmesh</code>创建一个简单的极轴投影图。下面是一个小脚本,它基本上产生了我要做的事情:</p>
<pre><code>from __future__ import unicode_literals
import numpy as np
import matplotlib.pyplot as plt
def make_plot(data,fig,subplot):
nphi,nt = data.shape
phi_coords = np.linspace(0,np.pi*2,nphi+1) - np.pi/2.
theta_coords = np.linspace(0,np.radians(35),nt+1)
ax = fig.add_subplot(subplot,projection='polar')
ax.set_thetagrids((45,90,135,180,225,270,315,360),(9,12,15,18,21,24,3,6))
ax.set_rgrids(np.arange(10,35,10),fmt='%s\u00b0')
theta,phi = np.meshgrid(phi_coords,theta_coords)
quadmesh = ax.pcolormesh(theta,phi,data)
ax.grid(True)
fig.colorbar(quadmesh,ax=ax)
return fig,ax
a = np.zeros((360,71)) + np.arange(360)[:,None]
b = np.random.random((360,71))
fig = plt.figure()
t1 = make_plot(a,fig,121)
t2 = make_plot(b,fig,122)
fig.savefig('test.png')
</code></pre>
<p>上面的脚本创建的绘图如下所示:</p>
<p><img src="https://i.stack.imgur.com/xaI7f.png" alt="enter image description here"/></p>
<p>我希望彩色条:</p>
<ol>
<li>不要重叠6个标签。</li>
<li>按比例缩放,使其与绘图高度大致相同。</li>
</ol>
<p>有什么诀窍能让它正常工作吗?(请注意,这个布局并不是我将要使用的唯一布局——例如,我可能使用1x2或4x4布局。。。似乎应该有办法将颜色条缩放到与关联绘图相同的高度…)</p>