2016-04-09 2 views
2

RadioButtonsウィジェットで狭い幅と大きな高さを取得するにはどうすればよく、重複しない丸いラジオボタンがありますか?RadioButtonsウィジェットで狭い幅と大きな高さを取得するにはどうすればいいですか?重複しない丸いラジオボタンはありますか?

plt.figure() 
rax = plt.axes([0.1, 0.1, 0.6, 0.6], frameon=True ,aspect='equal') 
labels = [str(i) for i in range(10)] 
radios = RadioButtons(rax, labels) 
for circle in radios.circles: # adjust radius here. The default is 0.05 
    circle.set_radius(0.02) 
plt.show() 

上記作品0.6であることを、たとえば、0.1と高さを、それが0.6に幅と軸インスタンスの高さを設定しますが、私は幅になりたいので:

plt.figure() 
rax = plt.axes([0.1, 0.1, 0.1, 0.6], frameon=True, aspect='equal') 
labels = [str(i) for i in range(10)] 
radios = RadioButtons(rax, labels) 
for circle in radios.circles: # adjust radius here. The default is 0.05 
    circle.set_radius(0.02) 
plt.show() 

これは単なるます結果は超小型で、幅0.1で高さ0.1です(アスペクト= '等価'が使用されていると思います)。狭いサイドバーが右側のプロットになります狭くて高いはずです。

答えて

0

あなたは、heightmatplotlib.patches.Circleパッチのプロパティを使用して、RadioButton」の作成後、円の高さを変えることができます。

import matplotlib.pyplot as plt 
from matplotlib.widgets import RadioButtons 

plt.figure() 
rax = plt.axes([0.1, 0.1, 0.1, 0.6], frameon=True) 
labels = [str(i) for i in range(10)] 
radios = RadioButtons(rax, labels) 

rpos = rax.get_position().get_points() 
fh = fig.get_figheight() 
fw = fig.get_figwidth() 
rscale = (rpos[:,1].ptp()/rpos[:,0].ptp()) * (fh/fw) 
for circ in radios.circles: 
    circ.height /= rscale 

plt.show() 

が重要なのは、我々がここにaspectequalには設定しないでください。代わりに人工的にサークルの高さを変更しようとしています。上の例では、軸の位置を使って高さをどれだけスケールするかを計算します。我々はまた、図のアスペクト比を考慮する必要があることに注意してください。

enter image description here

関連する問題