2017-08-17 92 views
2

我正在绘制极坐标投影的3x3网格(看起来有点像雷达图)。更改极坐标投影的子图的大小

例如正是在这个例子: https://matplotlib.org/examples/pylab_examples/polar_demo.html

我管理的绘制按预期的数据,但现在想通过一个变量来缩放每个极投影,使某些圈子的人比其他人更大,如下图下面。 scale either by width/height or area

当我在子图中循环时,我需要应用什么命令?

我试过打开/关闭自动缩放。 有可能gridspec.Gridspec()可能工作,但我不确定这是否是最好的解决方案,尽管它可能是。 谢谢

+0

,如果你发布一个最小的,完整的工作示例,但由于您使用的是极投影,它可能就足够了这会更容易用这个单独的变量来缩放半径。 – ml4294

回答

2

很好的问题。

您也可以直接使用fig.add_axes()有在你把你的曲线的连续空间:

f = plt.figure() 
ax = f.add_axes([0.05, 0.4, 0.2, 0.2], polar=True) # Left, Bottom, Width, Height 
ax2 = f.add_axes([0.30, 0.2, 0.6, 0.6], polar=True) 
r = np.arange(0, 2, 0.01) 
theta = 2 * np.pi * r 
ax.plot(theta, r) 
ax2.plot(theta, r) 

polar plot with different size


少好版本

你可以尝试设置不同轴创建时的大小:

import numpy as np 
import matplotlib.pyplot as plt 

r = np.arange(0, 2, 0.01) 
theta = 2 * np.pi * r 

ax = plt.subplot2grid((2,3), (0,0), polar=True) 
ax2 = plt.subplot2grid((2,3), (0,1), rowspan=2, colspan=2, polar=True) 
ax.plot(theta, r) 
ax2.plot(theta, r) 

polar plot with different size

可以比的2x3更大的网格,并有对剧情的大小更细的粒度。

(不介意不同的图形样式)

HTH

+0

谢谢 - 我没有想过使用比2x3更大的网格。这在某些情况下可能会起作用。我目前使用'gridspec(...,widthratios = [],heightratios = [])混合结果' – dreab

+0

谢谢 - 第二个选项似乎是最好的解决方案! – dreab

+0

是的,我也这么认为。接受答案让人们知道它解决了你的问题。 (如果它解决了你的问题!) – jrjc