我嘗試用matplotlib使用默認的gui組件繪製一些曲線,並且在選擇鼠標懸停功能應選擇的兩個y軸中有一些麻煩。默認情況下,似乎是ax2被選中,但我想用ax1代替。這可以通過一些簡單的方法解決嗎?帶雙縮放鼠標的Matplotlib
這是我現在用來繪製曲線的代碼。
最好的問候安德斯Olme
delta=np.median(np.diff(measurementvalues.measvalues))
myscale=10
myrange=(measurementvalues.lowerlimit - delta*myscale, measurementvalues.upperlimit + delta*myscale)
figure = plt.figure()
ax1 = figure.add_subplot(111)
(n, bins, patches) = ax1.hist(measurementvalues.measvalues, 10, range=myrange, normed=0, facecolor='green', alpha=0.75)
ax2 = ax1.twinx()
mean = np.average(measurementvalues.measvalues)
sigma = np.std(measurementvalues.measvalues)
y = mlab.normpdf(bins, mean, sigma)
ax2.plot(bins, y, 'r-', linewidth=1)
ax1.set_xlabel('Measvlues')
ax2.set_ylabel('Probability')
ax1.set_title(r'$\mathrm{Histogram\ of\ measvalues:}\ \mu=$'+str(mean)+r'$,\ \sigma=$'+str(sigma)+r'$$')
plt.grid(True)
plt.show()
你能澄清這個問題嗎?你是否試圖使用FigureCanvas.mpl_connect()與圖形進行交互?發佈的代碼只顯示數字如何生成;你能發佈描述你如何與數字交互的代碼嗎? – 2010-01-24 14:57:25
他正在談論交互式地塊右下角的座標標籤。不涉及回調,只是默認情節。 – matt 2011-06-21 04:46:23