本文整理汇总了Python中matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg.draw_idle方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTK3Agg.draw_idle方法的具体用法?Python FigureCanvasGTK3Agg.draw_idle怎么用?Python FigureCanvasGTK3Agg.draw_idle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg
的用法示例。
在下文中一共展示了FigureCanvasGTK3Agg.draw_idle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import draw_idle [as 别名]
class Main:
def __init__(self):
builder = Gtk.Builder()
builder.add_from_string(resource_string(__name__, 'gui.glade').decode())
builder.connect_signals(self)
self.window = builder.get_object("window")
self.figure = Figure(figsize=(100,250), dpi=75)
self.axis = self.figure.add_subplot(111)
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self.window)
imbox = builder.get_object("image_box")
imbox.pack_start(self.toolbar, False, False, 1)
imbox.pack_start(self.canvas, True, True, 1)
self.progress = builder.get_object("progressbar")
self.builder = builder
self.exit_thread = False
self.pen = None
self.notebook = builder.get_object("notebook")
def run(self):
self.window.show_all()
Gtk.main()
def execute_calc(self, widget, data=None):
page = self.notebook.get_current_page()
if page == 0:
lb = complex(eval(self.builder.get_object("j_lb").get_text()))
rt = complex(eval(self.builder.get_object("j_rt").get_text()))
func = lambda z: eval(self.builder.get_object("j_func").get_text())
it = self.builder.get_object("iteration_adj").get_value()
res = self.builder.get_object("resolution_adj").get_value()
Thread(target=self.julia, args=(lb, rt, func, it, res)).start()
elif page == 1:
lb = complex(eval(self.builder.get_object("m_lb").get_text()))
rt = complex(eval(self.builder.get_object("m_rt").get_text()))
func = lambda z,c: eval(self.builder.get_object("m_func").get_text())
it = self.builder.get_object("iteration_adj").get_value()
res = self.builder.get_object("resolution_adj").get_value()
Thread(target=self.mandelbrot, args=(lb, rt, func, it, res)).start()
elif page == 2:
axiom = self.builder.get_object("axiom").get_text()
rules = self.builder.get_object("rules").get_text()
it = int(self.builder.get_object("iteration_adj").get_value())
b = self.builder.get_object("commands_buffer")
cmds = b.get_text(b.get_start_iter(), b.get_end_iter(), False)
Thread(target=self.lindemayer, args=(axiom, rules, it, cmds)).start()
def plot_canvas(self, image, lb, rt):
self.axis.clear()
self.axis.imshow(image, extent=(lb.real, rt.real, lb.imag, rt.imag))
self.axis.set_title(self.builder.get_object("title").get_text())
self.canvas.draw_idle()
def plot_line(self, segments):
self.axis.clear()
points = []
for s in segments:
points += [(s[0][0],s[1][0]),(s[0][1],s[1][1]),'b-']
self.axis.plot(*points)
self.canvas.draw_idle()
def julia(self, lb, rt, func, it, res):
it = int(it)
h = (rt - lb).real
w = (rt - lb).imag
if w < h:
h = int(h/w * res)
w = int(res)
else :
w = int( w/h * res)
h = int(res)
x,y = np.ogrid[lb.real:rt.real:h*1j, lb.imag:rt.imag:w*1j]
z = x + 1j*y
zeros = np.zeros((w, h))
for i in range(it):
z = func(z)
zeros[(abs(z)>50) & (zeros==0)] = i
z[abs(z)>50] = 0
GObject.idle_add(self.progress.set_fraction, (i+1)/it)
if self.exit_thread:
self.exit_thread = False
return
zeros[zeros==0] = it + 1
self.plot_canvas(zeros.T, lb, rt)
def mandelbrot(self, lb, rt, func, it, res):
it = int(it)
h = (rt - lb).real
w = (rt - lb).imag
if w < h:
h = int(h/w * res)
w = int(res)
else :
#.........这里部分代码省略.........