我需要设置matplotlib小部件的高度,更改对齐方式或更改字体,但我不知道如何设置。在
屏幕截图:
5个单选按钮:
15个单选按钮:
下面是关键代码部分:
def evolvecallback_(self, notification):
global i
stats={}
results=[]
fitnesses=[]
for code,fit in evolve(i):
results.append(code)
stats[str(fit)]=code
fitnesses.append(str(fit))
i+=1
fig = plt.figure()
done=""
if found():
done=" - Solution found!"
print "Done!"
fig.canvas.set_window_title("Generation "+str(i)+". - Best migrating individuals"+done)
ax = plt.subplot(111)
ax.set_title(stats[str(fitnesses[0])])
l, = ax.plot(x, s0, lw=2, color='blue')
plt.subplots_adjust(left=0.4)
axcolor = 'lightgoldenrodyellow'
rax = plt.axes([0.05, 0.7, 0.15, 0.15], axisbg=axcolor)
radio = RadioButtons(rax, tuple(fitnesses))
def change(label):
hzdict = {}
x = np.arange(-5.0, 5.0, 0.01)
j=0
for i in tuple(results):
hzdict[fitnesses[j]]=eval(i)
j+=1
ax.set_title(stats[str(label)])
ydata = hzdict[str(label)]
l.set_ydata(ydata)
plt.draw()
radio.on_clicked(change)
plt.show()
该行设置单选按钮绘制到的轴的位置和大小:
把它改成
^{pr2}${a1}
明确地说,
rax
只是一个axes
对象,您要将单选按钮小部件添加到其中。在相关问题 更多 >
编程相关推荐