本文整理汇总了Python中matplotlib.backends.backend_gtk.FigureCanvasGTK类的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTK类的具体用法?Python FigureCanvasGTK怎么用?Python FigureCanvasGTK使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FigureCanvasGTK类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: displayGraph
def displayGraph(self, xaxis, yaxis, hist):
if(hist == None):
return
try:
dialog = gtk.Window()
figure = Figure(figsize=(6,4), dpi=72)
axis = figure.add_subplot(111)
canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
canvas.show()
dialog.add(canvas)
# empty axis if neccesary, and reset title and stuff
axis.clear()
axis.set_xlabel(xaxis)
axis.set_ylabel(yaxis)
if len(hist) > 1:
axis.plot(hist[0], 'r')
axis.plot(hist[1], 'g')
axis.plot(hist[2], 'b')
else:
axis.plot(hist[0], 'r')
dialog.show()
except ValueError:
sys.exit(1)
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:29,代码来源:Cyrinic.py
示例2: GtkTimeTicker
class GtkTimeTicker(TaskBaseWindow):
""" plot against time a specific item / set of items
Only works on arrays - so no singles!
"""
def __init__(self, tick_cb, title=None, dt=1.0, len=100, limits=None):
super(GtkTimeTicker, self).__init__(tick_cb=tick_cb, title=title, dt=dt)
self._no_given_limits = limits is None
self._len = len
self._fig = fig = Figure()
self._axis = axis = fig.add_subplot(111)
self._times = []
self._values = []
self._lines = []
self._gtkfig = FigureCanvasGTK(fig)
self._w.add(self._gtkfig)
self._w.set_size_request(300, 300)
self._w.show_all()
self._min_y, self._max_y = 0.0, 0.0
self._limits = limits
if limits:
self.setYLimits(*limits)
self._startTaskFirstTime()
def _update(self, result):
if len(result) == 0:
print "GtkTimeTicker: empty length result, nothing to do\r\n"
return
if len(result) > len(self._lines):
print "updating GtkTimeTicker to %s lines" % len(result)
for i in xrange(len(result) - len(self._lines)):
self._lines.append(self._axis.plot([],[])[0])
if len(self._values) != len(result):
# strange feature - if a new plot is added erase the old ones.
self._values = [[] for i in xrange(len(result))]
if self._limits:
self.setYLimits(*self._limits)
self._min_y, self._max_y = min(self._min_y, *result), max(self._max_y, *result)
self._times.append(time.time() - self._start)
for i, v in enumerate(result):
self._values[i].append(v)
if len(self._values[0]) > self._len:
for values in self._values:
del values[:(len(values) - self._len)]
del self._times[:(len(self._times) - self._len)]
self.updatePlot()
def updatePlot(self):
# TODO - better way then resetting the whole number of points.
for line, values in zip(self._lines, self._values):
line.set_data(self._times, values)
if len(line._x) != len(line._y):
import pdb; pdb.set_trace()
self._axis.set_xlim(self._times[0], self._times[-1])
if self._no_given_limits:
self.setYLimits(self._min_y, self._max_y)
self._gtkfig.draw()
def setYLimits(self, lim_min, lim_max):
self._axis.set_ylim(lim_min, lim_max)
开发者ID:alon,项目名称:burst,代码行数:60,代码来源:widgets.py
示例3: __init__
def __init__(self):
self.lastUpdate = datetime.now()
self.thread = None
self.lastBest = None
self.builder = gtk.Builder()
self.builder.add_from_file(GUI_FILENAME)
# init default values (due to Glade 3.7 bug)
self.builder.get_object("input_Ax").set_value(brach.A[0])
self.builder.get_object("input_Ay").set_value(brach.A[1])
self.builder.get_object("input_Bx").set_value(brach.B[0])
self.builder.get_object("input_By").set_value(brach.B[1])
self.builder.get_object("input_population_size").set_value(brach.POPULATION_MAX)
self.builder.get_object("input_elitism").set_value(brach.ELITISM*100)
self.builder.get_object("input_points").set_value(brach.POINTS_INIT)
self.builder.get_object("input_crossover").set_value(brach.CROSSOVER*100)
self.builder.get_object("input_crossover_len").set_value(brach.CROSSOVER_LEN_MAX*100)
self.builder.get_object("input_mutation").set_value(brach.MUTATION*100)
self.builder.get_object("input_mutation_y").set_value(brach.MUTATION_Y*100)
self.builder.get_object("input_mutation_burst").set_value(brach.MUTATION_BURST*100)
# init the input_selection_type
selection_model = gtk.ListStore(str)
selection_model.append(["Tournament"])
selection_model.append(["Roulette"])
selection_box = self.builder.get_object("input_selection_type")
selection_box.set_model(selection_model)
cell = gtk.CellRendererText()
selection_box.pack_start(cell)
selection_box.add_attribute(cell,'text',0)
selection_box.set_active(0)
self.builder.get_object("button_save").set_sensitive(False)
self.running = False
# init graphs
self.fig_best = Figure(figsize=(400, 400))
self.fig_hist = Figure(figsize=(400, 200))
self.canvas_best = FigureCanvasGTK(self.fig_best)
self.canvas_hist = FigureCanvasGTK(self.fig_hist)
self.canvas_best.show()
self.canvas_hist.show()
self.hbox_best = self.builder.get_object("hbox_graph_best")
self.hbox_hist = self.builder.get_object("hbox_graph_hist")
self.hbox_best.pack_start(self.canvas_best, True, True)
self.hbox_hist.pack_start(self.canvas_hist, True, True)
# show window
self.builder.connect_signals(self)
window = self.builder.get_object('window_main')
window.set_title("Brachistochrone curve")
window.show()
开发者ID:Rafael-Ribeiro,项目名称:ai-intro,代码行数:59,代码来源:gui.py
示例4: __init__
class Onus:
def __init__(self):
#self.gladefile = "onus.glade"
self.gladefile = "../onus.glade"
self.wTree = gtk.glade.XML(self.gladefile, "mainWindow")
FILES = [ "../../0_10_0.TXT" ]
t = 0
time = []
heart_rate = []
step_count = []
activity = []
# Get the Data
for file in FILES:
infile = open(file,"r")
data_section = 0
while 1:
line = infile.readline()
if not line:
break
moment = line.split(",")
time.append( t )
t += 1
step_count.append( moment[0] )
heart_rate.append( moment[1] )
activity.append( moment[2] )
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.axis.set_xlabel('Time (minutes)')
self.axis.set_ylabel('Heart Rate (bpm)')
self.axis.set_title('Activity')
self.axis.grid(True)
self.axis.plot(time, heart_rate, time, step_count, time, activity)
self.axis.legend(["Heart Rate", "Step Count", "Activity"])
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
self.graphview = self.wTree.get_widget("vbox2")
self.graphview.pack_start(self.canvas, True, True)
#Create our dictionay and connect it
dic = { "on_mainWindow_destroy" : gtk.main_quit, "on_connect" : self.on_connect, "on_import" : self.on_import }
self.wTree.signal_autoconnect(dic)
def on_connect(self, widget):
#dan = Fetch()
#.start()
self.statusbar1 = self.wTree.get_widget("statusbar1")
self.statusbar1.push(0, "Connected")
def on_import(self, widget):
self.statusbar1 = self.wTree.get_widget("statusbar1")
self.statusbar1.push(0, "Importing")
开发者ID:FitnessMonitor,项目名称:Fitness-Monitor,代码行数:57,代码来源:onus.py
示例5: init_chart
def init_chart(self):
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.axis.grid(True)
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
self.vbox.pack_start(self.canvas, True, True)
开发者ID:JHSaunders,项目名称:masters,代码行数:7,代码来源:result_viewer.py
示例6: __init__
def __init__(self):
gladefile = os.path.join(roslib.packages.get_pkg_dir('pplan'), "glade/pplan_gui.glade")
self.windowname = "main_window"
self.w_tree = gtk.glade.XML(gladefile, self.windowname)
dic = {'on_main_window_destroy' : gtk.main_quit,
'on_get_data_button_clicked' : self.get_data,
'on_make_graph_button_clicked' : self.make_graph,
'on_calc_kernel_button_clicked' : self.calc_kernel,
'on_plan_path_button_clicked' : self.plan_path,
}
self.w_tree.signal_autoconnect(dic)
main_window = self.w_tree.get_widget('main_window')
# setup matplotlib stuff on first notebook page (empty graph)
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.axis.set_xlabel('Longitude')
self.axis.set_ylabel('Latitude')
self.axis.set_title('')
self.axis.grid(True)
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
self.graphview = self.w_tree.get_widget('vbox1')
self.graphview.pack_start(self.canvas, True, True)
self.nav_bar = NavigationToolbar(self.canvas, main_window)
self.graphview.pack_start(self.nav_bar, False, True)
run_dir = sys.argv[1]
self.settings = pplan.PPlanSettings(run_dir)
# initialize the data directory, if not done already
self.store = ppas.Store(self.settings.data_dir)
self.plot_graph()
self.plot_path()
开发者ID:jonbinney,项目名称:informative_path_planning,代码行数:35,代码来源:gui.py
示例7: createDBGraph
def createDBGraph(self, widget):
self.axis.clear()
self.axis.set_xlabel('Samples (n)')
self.axis.set_ylabel('Value (-)')
self.axis.set_title('Another Graph (click on the columnheader to sort)')
self.axis.grid(True)
# get columns from listmodel
age = []
for row in self.listmodel:
age.append(row[1])
size = []
for row in self.listmodel:
size.append(row[2])
# get number of rows
N = len(age)
ind = arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
p1 = self.axis.bar(ind, age, width, color='b')
p2 = self.axis.bar(ind+width, size, width, color='r')
# destroy graph if it already exists
while True:
try:
self.canvas2.destroy()
break
except:
print "nothing to destroy"
break
self.canvas2 = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas2.show()
self.grahview = self.wTree.get_widget("vbox2")
self.grahview.pack_start(self.canvas2, True, True)
开发者ID:sauravkumar2014,项目名称:ASCEND,代码行数:35,代码来源:pygladematplotlib.py
示例8: clouddetectsave
def clouddetectsave(self,obj):
dialog= gtk.FileChooserDialog("Save Cloud Detection Graph ",
None,
gtk.FILE_CHOOSER_ACTION_SAVE,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
dialog.set_default_response(gtk.RESPONSE_OK)
dialog.set_current_folder(os.curdir)
dialog.set_do_overwrite_confirmation(True)
filter = gtk.FileFilter()
filter.set_name("image(png) file")
filter.add_pattern("*.png")
dialog.add_filter(filter)
response=dialog.run()
if response == gtk.RESPONSE_OK:
plotimagefile=dialog.get_filename()
dialog.destroy()
#self.canvas1.print_figure1(plotimagefile, 72,'w', 'w','portrait')
self.figure1.savefig(plotimagefile)
self.canvas1.destroy()
self.canvas1 = FigureCanvasGTK(self.figure1)
self.graphview.pack_start(self.canvas1, True,True)
self.canvas1.show()
elif response == gtk.RESPONSE_CANCEL:
print "no file is selected"
dialog.destroy()
self.canvas1.show()
开发者ID:BackupTheBerlios,项目名称:freeceilo-svn,代码行数:27,代码来源:gui.py
示例9: __init__
def __init__(self):
self.gladefile = "attenuation_calc.glade"
windowname = "MainWindow"
self.wTree=gtk.glade.XML(self.gladefile, windowname)
dic = { "on_GetDataButton_clicked" : self.button1_clicked,
"on_SaveImageMenuItem_activate" : self.save_image,
"on_ExportMenuItem_activate" : self.save_data,
"on_MainWindow_destroy" : (gtk.main_quit) ,
"on_QuitMenuItem_activate" : (gtk.main_quit),
"on_about_menuitem_activate" : self.about }
self.wTree.signal_autoconnect(dic)
self.figure = Figure(figsize=(6,4), dpi=72)
self.axis = self.figure.add_subplot(111)
self.axis.set_xlabel('Energies')
self.axis.set_ylabel('Attenuation Length (microns)')
self.axis.set_title('Attenuation Lengths vs Energy')
self.axis.grid(True)
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.graphview = self.wTree.get_widget("vbox1")
self.graphview.pack_start(self.canvas,True,True)
#self.graphview.pack_start(self.canvas,True,True)
self.wTree.get_widget(windowname).maximize()
self.E = {}
self.attlen = {}
return
开发者ID:davepeake,项目名称:XRay_Attenuation,代码行数:32,代码来源:attenuation_calc.py
示例10: __init__
def __init__(self):
# Le decimos a nuestro programa el nombre del archivo glade
self.widgets = gtk.glade.XML("interface.glade")
# Creamos un pequeño diccionario que contiene las señales definidas en
# glade y su respectivo método (o llamada)
signals = { "on_buttonIniciar_clicked" : self.on_buttonIniciar_clicked,
"on_about_dialog_clicked" : self.on_about_dialog_clicked,
"on_exit_clicked" : gtk.main_quit, # al presionar el boton salir, sale de la aplicacion
"gtk_main_quit" : gtk.main_quit } #
# Luego se auto-conectan las señales.
self.widgets.signal_autoconnect(signals)
# Nota: Otra forma de hacerlo es No crear el diccionario signals y
# solo usar "self.widgets.signal_autoconnect(self)" -->Ojo con el self
# Ahora obtenemos del archivo glade los widgets que vamos a utilizar
self.labelTiempo = self.widgets.get_widget("labelTiempo") #label de tiempo
self.buttonIniciar = self.widgets.get_widget("buttonIniciar") #boton iniciar
self.aboutDialog = self.widgets.get_widget("aboutDialog") #dialogo acerca de
#Definición del widget que manejará la gráfica
self.figure = Figure(figsize=(6,4), dpi=60)
self.axis = self.figure.add_subplot(111)
self.axis.set_xlabel('X')
self.axis.set_ylabel('Y')
self.axis.set_title('Graph')
self.axis.grid(True)
#Agregar la gráfica a la caja vertical
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.graphview = self.widgets.get_widget("matplot")
self.graphview.pack_start(self.canvas, True, True)
开发者ID:zerohours,项目名称:ardu-mrua,代码行数:35,代码来源:arduino.py
示例11: clear_figure
def clear_figure(self):
self.axes.clear()
self.canvas.destroy()
self.axes.grid(True)
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.widget.pack_start(self.canvas, True, True)
开发者ID:aalonso,项目名称:sigbox,代码行数:7,代码来源:graphic.py
示例12: power_spectrum
def power_spectrum(self, x, n, fs):
self.axes.clear()
self.axes.grid(True)
self.axes.psd(x, NFFT = n, Fs = fs)
self.canvas.destroy()
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.widget.pack_start(self.canvas, True, True)
开发者ID:aalonso,项目名称:sigbox,代码行数:8,代码来源:graphic.py
示例13: autocor
def autocor(self, x):
self.axes.clear()
self.axes.grid(True)
self.axes.acorr(x)
self.canvas.destroy()
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.widget.pack_start(self.canvas, True, True)
开发者ID:aalonso,项目名称:sigbox,代码行数:8,代码来源:graphic.py
示例14: semilogy
def semilogy(self, x, y):
self.axes.clear()
self.axes.grid(True)
self.axes.semilogy(x, y)
self.canvas.destroy()
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.widget.pack_start(self.canvas, True, True)
开发者ID:aalonso,项目名称:sigbox,代码行数:8,代码来源:graphic.py
示例15: draw
def draw(self):
'Draw or re-draw the plot, possibly showing some labels'
try: self.graphview.remove(self.canvas)
except: pass
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.mpl_connect('pick_event', self.pick_handler)
self.canvas.show()
self.graphview = self.app.tree.get_widget("vbox_plot")
self.graphview.pack_start(self.canvas, True, True)
开发者ID:daob,项目名称:JruleMplus,代码行数:9,代码来源:JruleMplus.py
示例16: __init__
def __init__(self, tick_cb, title=None, dt=1.0, len=100, limits=None):
super(GtkTimeTicker, self).__init__(tick_cb=tick_cb, title=title, dt=dt)
self._no_given_limits = limits is None
self._len = len
self._fig = fig = Figure()
self._axis = axis = fig.add_subplot(111)
self._times = []
self._values = []
self._lines = []
self._gtkfig = FigureCanvasGTK(fig)
self._w.add(self._gtkfig)
self._w.set_size_request(300, 300)
self._w.show_all()
self._min_y, self._max_y = 0.0, 0.0
self._limits = limits
if limits:
self.setYLimits(*limits)
self._startTaskFirstTime()
开发者ID:alon,项目名称:burst,代码行数:18,代码来源:widgets.py
示例17: createProjectGraph
def createProjectGraph(self, widget):
while True:
try:
# empty axis if neccesary, and reset title and stuff
self.axis.clear()
self.axis.set_xlabel('Yepper')
self.axis.set_ylabel('Flabber')
self.axis.set_title('A Graph')
self.axis.grid(True)
# get data
age = self.wTree.get_widget("entry2").get_text()
size = self.wTree.get_widget("entry3").get_text()
age != ""
size != ""
N = 1
ind = arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
p1 = self.axis.bar(ind, int(age), width, color='r')
p2 = self.axis.bar(ind+width, int(size), width, color='y')
self.axis.legend((p1[0], p2[0]), ("Age", "Size"), shadow = True)
#self.axis.set_xticks(ind+width, ('G1') )
self.axis.set_xlim(-width,len(ind))
self.canvas.destroy()
self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
self.canvas.show()
self.grahview = self.wTree.get_widget("vbox1")
self.grahview.pack_start(self.canvas, True, True)
break
except ValueError:
self.wDialog = gtk.glade.XML("project2.glade", "cannotCreateProjGraph")
close = self.wDialog.get_widget("cannotCreateProjGraph")
response = close.run()
if response == gtk.RESPONSE_OK:
close.destroy()
break
开发者ID:sauravkumar2014,项目名称:ASCEND,代码行数:42,代码来源:pygladematplotlib.py
示例18: button1_clicked
def button1_clicked(self,widget):
self.graphview.remove(self.canvas) # important else they just get inserted again each time (not replaced)
self.axis.cla()
eltext = self.wTree.get_widget("ElementText").get_text()
if eltext.find(',') == -1:
el = self.wTree.get_widget("ElementText").get_text().split()
else:
el = self.wTree.get_widget("ElementText").get_text().split(',')
[self.E,self.attlen] = nx.calclengths(el)
for e in self.attlen.keys():
self.axis.loglog(self.E[e],self.attlen[e],label=e);
self.axis.set_xlabel('Energy (MeV)')
self.axis.set_ylabel('Attenuation Length (cm)')
self.axis.set_title('Attenuation Lengths vs Energy')
self.axis.legend(loc='lower right')
self.axis.grid(True)
self.canvas.destroy()
self.canvas = FigureCanvasGTK(self.figure)
self.canvas.show()
self.graphview = self.wTree.get_widget("vbox1")
self.graphview.pack_end(self.canvas, True, True)
开发者ID:davepeake,项目名称:XRay_Attenuation,代码行数:22,代码来源:attenuation_calc.py
示例19: __init__
def __init__(self,tipo):
self.cuento = 0
self.magico = 800
self.app = None
self.tipo = tipo
self.data = np.array([])
self.fechas = np.array([])
self.dpi = 100
self.f = Figure((3.0, 3.0), dpi=self.dpi)
self.f.subplots_adjust(hspace=1, left=.05, right = .99, top=.92 )
self.a = self.f.add_subplot(111)
self.a.set_axis_bgcolor('white')
setp(self.a.get_xticklabels(), fontsize=8)
setp(self.a.get_yticklabels(), fontsize=8)
self.plot_data= self.a.plot(
self.data,
linewidth= 1.4,
color= tipo.color,
)[0]
self.plot_data2 = self.a.plot(
np.array([]),
linestyle= "--",
linewidth= 1.4,
color= "g",
)[0]
self.a.grid(True)
# self.a.set_xlabel('Time')
self.a.set_ylabel(tipo.formal)
self.canvas = FigureCanvas(self.f)
开发者ID:Ruijunzhang,项目名称:Donnees-Acquisition-Data-software,代码行数:29,代码来源:widget_graficos.py
示例20: setup_Plots
def setup_Plots(self,box):
self.plot_Figure = Figure(figsize=(5,4), dpi=72)
self.plot = self.plot_Figure.add_subplot(111)
self.plot.plot(0,0,'-')
self.plot_Canvas = FigureCanvas(self.plot_Figure)
self.plot_Canvas.set_size_request(int(self.plot_Window_Fraction_x*self.x_size),
int(self.plot_Window_Fraction_y*self.y_size))
self.plot_Canvas.show()
box.add(self.plot_Canvas)
开发者ID:dgastler,项目名称:gene-sim,代码行数:9,代码来源:GUI.py
注:本文中的matplotlib.backends.backend_gtk.FigureCanvasGTK类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论