2011-11-15 26 views
5

enter image description here奇蹟雙胞胎電源「縮放到矩形」激活?

當matplotlib圖形顯示時,有沒有辦法讓「Zoom to rectangle」工具默認自動激活?

import numpy as np 
import matplotlib.pyplot as plt 
x = np.arange(-300, 300) 
y = x**2-7*x 
fig = plt.figure() 
ax = fig.add_subplot(1,1,1) 
plt.plot(x, y) 
# Add something here to activate the "Zoom to rectangle" tool? 
plt.show() 
+1

這將可能是後端的依賴。你使用哪個後端?要清楚,我不知道答案。 :) –

+0

我的第一條評論是錯的:http://matplotlib.sourceforge.net/api/backend_bases_api.html#matplotlib.backend_bases.NavigationToolbar2.zoom不知道在哪個對象上必須調用這個方法。 –

+0

我正在使用GtkAgg,以防萬一。 – unutbu

回答

4

這個工作對我來說:

plt.get_current_fig_manager().toolbar.zoom() 
+0

優秀。非常感謝。 – unutbu