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()
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)
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)
def __init__(self, owner): label = "Grayscale analysis" gtk.Frame.__init__(self, label) self.owner = owner self.DMS = self.owner.DMS self.grayscale_fig = plt.Figure(figsize=(50,40), dpi=100) self.grayscale_fig.subplots_adjust(left=0.02, right=0.98, wspace=0.3) self.grayscale_plot_img = self.grayscale_fig.add_subplot(121) self.grayscale_plot_img.get_xaxis().set_visible(False) self.grayscale_plot_img.get_yaxis().set_visible(False) self.grayscale_plot_img_ax = None self.grayscale_plot_img_ax2 = None self.grayscale_plot = self.grayscale_fig.add_subplot(122) self.grayscale_plot.axis("tight") self.grayscale_plot.get_xaxis().set_visible(False) grayscale_canvas = FigureCanvas(self.grayscale_fig) grayscale_canvas.show() grayscale_canvas.set_size_request(400,150) self.add(grayscale_canvas) self.show()
class WidgetsWrapper: def __init__(self): self.widgets = gtk.glade.XML('mpl_with_glade.glade') self.widgets.signal_autoconnect(GladeHandlers.__dict__) self.figure = Figure(figsize=(8,6), dpi=72) self.axis = self.figure.add_subplot(111) t = arange(0.0,3.0,0.01) s = sin(2*pi*t) self.axis.plot(t,s) self.axis.set_xlabel('time (s)') self.axis.set_ylabel('voltage') self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea self.canvas.show() self['vboxMain'].pack_start(self.canvas, gtk.TRUE, gtk.TRUE) self['vboxMain'].show() # below is optional if you want the navigation toolbar self.navToolbar = NavigationToolbar(self.canvas, self['windowMain']) self.navToolbar.lastDir = '/var/tmp/' self['vboxMain'].pack_start(self.navToolbar) self.navToolbar.show() sep = gtk.HSeparator() sep.show() self['vboxMain'].pack_start(sep, gtk.TRUE, gtk.TRUE) self['vboxMain'].reorder_child(self['buttonClickMe'],-1) def __getitem__(self, key): return self.widgets.get_widget(key)
def __init__(self, type=PointType.Default, title='', xupper=1.0, yupper=1.0, xlower=0, ylower=0, xlabel='', ylabel='', grid=True): self.type = type self.model = None self.figure = Figure() self.axis = self.figure.add_subplot(111) self.axis.set_title(title) self.axis.set_xlabel(xlabel) self.axis.set_ylabel(ylabel) self.axis.grid(grid) self.axis.set_xbound(xlower, xupper) self.axis.set_ybound(ylower, yupper) self.axis.set_autoscale_on(False) self.canvas = FigureCanvasGTK(self.figure) self.line, = self.axis.plot([], []) self.axis.set_position([0.15, 0.1, 0.80, 0.85]) # There seems no better way to animate matplotlib figures # than having a separate periodic refresh which calls # a synchronous draw on the canvas self.cid = gobject.timeout_add(200, self.expose_event)
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
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)
def __init__(self): self.widgets = gtk.glade.XML('mpl_with_glade.glade') self.widgets.signal_autoconnect(GladeHandlers.__dict__) self.figure = Figure(figsize=(8, 6), dpi=72) self.axis = self.figure.add_subplot(111) t = arange(0.0, 3.0, 0.01) s = sin(2 * pi * t) self.axis.plot(t, s) self.axis.set_xlabel('time (s)') self.axis.set_ylabel('voltage') self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea self.canvas.show() self['vboxMain'].pack_start(self.canvas, gtk.TRUE, gtk.TRUE) self['vboxMain'].show() # below is optional if you want the navigation toolbar self.navToolbar = NavigationToolbar(self.canvas, self['windowMain']) self.navToolbar.lastDir = '/var/tmp/' self['vboxMain'].pack_start(self.navToolbar) self.navToolbar.show() sep = gtk.HSeparator() sep.show() self['vboxMain'].pack_start(sep, gtk.TRUE, gtk.TRUE) self['vboxMain'].reorder_child(self['buttonClickMe'], -1)
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()
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")
class GraphView: def __init__(self, type=PointType.Default, title='', xupper=1.0, yupper=1.0, xlower=0, ylower=0, xlabel='', ylabel='', grid=True): self.type = type self.model = None self.figure = Figure() self.axis = self.figure.add_subplot(111) self.axis.set_title(title) self.axis.set_xlabel(xlabel) self.axis.set_ylabel(ylabel) self.axis.grid(grid) self.axis.set_xbound(xlower, xupper) self.axis.set_ybound(ylower, yupper) self.axis.set_autoscale_on(False) self.canvas = FigureCanvasGTK(self.figure) self.line, = self.axis.plot([], []) self.axis.set_position([0.15, 0.1, 0.80, 0.85]) # There seems no better way to animate matplotlib figures # than having a separate periodic refresh which calls # a synchronous draw on the canvas self.cid = gobject.timeout_add(200, self.expose_event) def SetSpec(self, spec): self.type = spec.type #self.axis.set_title (spec.title); self.axis.set_xbound(spec.xlower, spec.xupper) self.axis.set_ybound(spec.ylower, spec.yupper) #self.axis.set_xlabel (spec.xlabel) text = self.axis.set_ylabel(spec.title) #if len (spec.title) > 16: text.set_size('small') self.canvas.set_tooltip_text(spec.title) def SetWorldModel(self, model): self.model = model def expose_event(self): x, y = self.model.GetPoints(self.type) self.line.set_xdata(x) self.line.set_ydata(y) self.figure.canvas.draw() return True
def __init__(self,): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("destroy", self.pgquit) self.window.set_title("Plot window") self.window.set_border_width(5) self.window.set_default_size(800,600) self.table = gtk.Table(10,4, True) self.window.add(self.table) self.table.show() # ========================================== self.figure = Figure(figsize=(6,4), dpi=72) self.axis = self.figure.add_subplot(111) self.axis.set_title('tip-tilt log plotter for Pyramid') self.axis.set_xlabel('Iteration') self.axis.set_ylabel('Tip-Tilt residual (micron)') self.axis.set_ylim([-80.0, 80.0]) self.axis.set_ylim([-0.35, 0.35]) self.axis.grid(True) x = np.arange(100) self.axis.plot(x) self.axis.plot(x) self.canvas = FigureCanvasGTK(self.figure) self.canvas.show() self.table.attach(self.canvas, 0, 4, 0,9) # ========================================== butt = gtk.Button("START") butt.connect("clicked", self.b_clicked1) self.table.attach(butt, 0, 1, 9, 10) butt.show() self.butt = gtk.Button("STOP") self.butt.connect("clicked", self.b_clicked2) self.table.attach(self.butt, 1, 2, 9, 10) self.butt.show() #self.lbl = gtk.Label("ExpTime:") #self.butt.connect("clicked", self.b_clicked3) #self.table.attach(self.lbl, 2, 3, 9, 10) #self.lbl.show() self.lbl_tint = gtk.Label("") self.table.attach(self.lbl_tint, 3, 4, 9, 10) self.lbl_tint.show() # ---------------- self.window.show()
class AppGui(object): def __init__(self): gladefile = "pygtk-matplotlib.glade" self.windowname = "main_window" self.wTree = gtk.glade.XML(gladefile, self.windowname) dic = { "on_main_window_destroy" : gtk.main_quit, "on_button1_clicked" : self.render_graph, #"on_button3_clicked" : self.fillTree, #"on_notebook1_switch_page" : self.selectNotebookPage, #"on_treeview1_button_press_event" : self.clickTree, #"on_button2_clicked" : self.createProjectGraph, } self.wTree.signal_autoconnect(dic) # setup matplotlib stuff on first notebook page (empty graph) self.figure = Figure(figsize=(6,4), dpi=72) self.axis = self.figure.add_subplot(1,1,1) self.axis.set_xlabel('Yepper') self.axis.set_ylabel('Flabber') self.axis.set_title('An Empty Graph') self.axis.grid(True) self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea self.canvas.show() # Adding matplotlib canvas to our window self.graphview = self.wTree.get_widget("main_vbox") self.graphview.pack_start(self.canvas, True, True) #self.listview = self.wTree.get_widget("treeview1") #self.listmodel = gtk.ListStore(str, int, int, str, str) #self.listview.set_model(self.listmodel) #renderer = gtk.CellRendererText() #column = gtk.TreeViewColumn("Name",renderer, text=0) #column.set_clickable(True) #column.set_sort_column_id(0) #column.connect("clicked", self.createDBGraph) #column.set_resizable(True) #self.listview.append_column(column) self.wTree.get_widget(self.windowname).show() def render_graph(self, widget): print "render_graph()" 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)
def __init__(self): gtk.Window.__init__(self) self.set_default_size(600, 600) self.connect('destroy', lambda win: gtk.main_quit()) self.set_title('GtkListStore demo') self.set_border_width(8) vbox = gtk.VBox(False, 8) self.add(vbox) label = gtk.Label('Double click a row to plot the data') vbox.pack_start(label, False, False) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) vbox.pack_start(sw, True, True) model = self.create_model() self.treeview = gtk.TreeView(model) self.treeview.set_rules_hint(True) fig = Figure(figsize=(6,4)) self.canvas = FigureCanvas(fig) # a gtk.DrawingArea vbox.pack_start(self.canvas, True, True) ax = fig.add_subplot(111) self.line, = ax.plot(self.data[0,:], 'go') # plot the first row self.treeview.connect('row-activated', self.plot_row) sw.add(self.treeview) self.add_columns() self.add_events(gdk.BUTTON_PRESS_MASK | gdk.KEY_PRESS_MASK| gdk.KEY_RELEASE_MASK)
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)
def update_uttview(self): utt = self.corpusview.current_utt origspeech_specfig = Figure(dpi=72) origspeech_specplot = origspeech_specfig.add_subplot(111) origspeech_specplot.specgram(utt["waveform"].samples, Fs=utt["waveform"].samplerate, NFFT=128, noverlap=64) origspeech_speccanvas = FigureCanvasGTK(origspeech_specfig) framecontents = self.frame_specutt.get_children() if framecontents: self.frame_specutt.remove(framecontents[0]) self.frame_specutt.add(origspeech_speccanvas) self.entry_transcription.set_text(self.corpusview.transcriptions[self.corpusview.worklist[self.corpusview.current_index][0]]) self.entry_comment.set_text(self.corpusview.comments[self.corpusview.worklist[self.corpusview.current_index][0]]) self.buttonbox_words = gtk.HButtonBox() words = utt.get_relation("Word").as_list() for i, word in enumerate(words): button = gtk.Button() button.wordindex = i button.connect("clicked", self.change_wordview) button.set_label(word["name"]) self.buttonbox_words.pack_end(button) framecontents = self.frame_words.get_children() if framecontents: self.frame_words.remove(framecontents[0]) self.frame_words.add(self.buttonbox_words) self.table_utt.show_all() self.update_wordview()
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)
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)
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)
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()
def __init__(self, data_source): years = mdates.YearLocator(2) # every year months = mdates.MonthLocator() # every month yearsFmt = mdates.DateFormatter('%y') dt_list, ssn_list = data_source.get_plotting_data() self.figure = Figure(figsize=(12,8), dpi=72) self.figure.patch.set_facecolor('white') self.figure.subplots_adjust(bottom=0.2) self.axis = self.figure.add_subplot(111) self.axis.plot_date(dt_list, ssn_list, '-', lw=2) self.axis.axvline(date.today(), color='r') # format the ticks self.axis.xaxis.set_major_locator(years) self.axis.xaxis.set_major_formatter(yearsFmt) self.axis.grid(True) # rotates and right aligns the x labels, and moves the bottom of the # axes up to make room for them # The following line currently breaks voacapgui if the thumbnail is # inserted into a panel # self.figure.autofmt_xdate(rotation=90) self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
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)
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)
class DataManager(gtk.Window): numRows, numCols = 20,10 data = random((numRows, numCols)) def __init__(self): gtk.Window.__init__(self) self.set_default_size(600, 600) self.connect('destroy', lambda win: gtk.main_quit()) self.set_title('GtkListStore demo') self.set_border_width(8) vbox = gtk.VBox(False, 8) self.add(vbox) label = gtk.Label('Double click a row to plot the data') vbox.pack_start(label, False, False) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) vbox.pack_start(sw, True, True) model = self.create_model() self.treeview = gtk.TreeView(model) self.treeview.set_rules_hint(True) fig = Figure(figsize=(6,4)) self.canvas = FigureCanvas(fig) # a gtk.DrawingArea vbox.pack_start(self.canvas, True, True) ax = fig.add_subplot(111) self.line, = ax.plot(self.data[0,:], 'go') # plot the first row self.treeview.connect('row-activated', self.plot_row) sw.add(self.treeview) self.add_columns() self.add_events(gdk.BUTTON_PRESS_MASK | gdk.KEY_PRESS_MASK| gdk.KEY_RELEASE_MASK) def plot_row(self, treeview, path, view_column): ind, = path # get the index into data points = self.data[ind,:] self.line.set_ydata(points) self.canvas.draw() def add_columns(self): for i in range(self.numCols): column = gtk.TreeViewColumn('%d'%i, gtk.CellRendererText(), text=i) self.treeview.append_column(column) def create_model(self): types = [float]*self.numCols store = gtk.ListStore(*types) for row in self.data: store.append(row) return store
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)
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)
def __init__(self, filename=None, query=""): builder = gtk.Builder() builder.add_from_file(os.path.join(getdatapath(), "master_gui.ui")) self.root = builder.get_object('mainWin') builder.connect_signals(self) self.tlbStart = builder.get_object('tlbStart') self.tlbPause = builder.get_object('tlbPause') self.tlbStop = builder.get_object('tlbStop') self.statusbar = builder.get_object('statusbar1') self.imgQueryStatus = builder.get_object('imgQueryStatus') self.txtQueryQuery = builder.get_object('txtQueryQuery') self.graphContainer = builder.get_object('graphContainer') if matplotlib: # setup matplotlib stuff on first notebook page (empty graph) #self.figure = Figure(figsize=(6,4), dpi=72) self.figure = Figure() self.axis = self.figure.add_subplot(111) self.axis.set_xlabel('Time (secs.)') self.axis.set_ylabel('Size of waiting list') self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea self.canvas.show() self.graphContainer.pack_start(self.canvas, True, True) self.graph_lines = [] self.graph_data = [] for i in range(1, size): self.graph_lines += self.axis.plot([0]) self.graph_data += [[0]] print self.graph_data print self.graph_lines self.axis.set_ylim(0, 100) self.axis.set_xlim(0, 10) self.root.show_all() self.running = False if filename: self.loadFile(filename) if query: self.txtQueryQuery.set_text(query) gobject.idle_add(self.on_start)
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)
class Graph(gtk.Frame): def __init__(self, label): self.plots = dict() gtk.Frame.__init__(self) self.set_label(label) self.fig = Figure(figsize=(6, 4)) self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea #self.add(self.canvas) vbox = gtk.VBox() vbox.pack_start(self.canvas) toolbar = NavigationToolbar(self.canvas, self) vbox.pack_start(toolbar, False, False) self.add(vbox) def clear(self): self.fig.clear() self.plots.clear() def draw(self, symbol, dates, values): years = YearLocator() # every year months = MonthLocator() # every month yearsFmt = DateFormatter('%Y') #monthFmt = DateFormatter('%m') # coeffs = polyfit(dates, values, 3) # besty = polyval(coeffs, dates) ax = self.fig.add_subplot(111) ax.plot(dates, values, label=symbol) ax.legend(loc='best', prop=FontProperties(size='9')) ax.grid(True) ax.xaxis.set_major_locator(years) ax.xaxis.set_major_formatter(yearsFmt) #ax.xaxis.set_minor_formatter(monthFmt) ax.xaxis.set_minor_locator(months) ax.autoscale_view() self.plots[symbol] = ax #self.fig1.autofmt_xdate() self.canvas.draw() def insert_annotations(self, symbol, cursor): ax = self.plots[symbol] for row in cursor: ax.annotate(row[0], xy=(row[1], row[2])) self.canvas.draw()
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)
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)
class JwsFileChooserDialog(gtk.FileChooserDialog): def __init__(self, parent, current_folder=None, title=_("Open spectra...")): gtk.FileChooserDialog.__init__( self, title=title, parent=parent, action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_ADD, gtk.RESPONSE_OK)) self.figure = Figure(figsize=(5, 4)) self.canvas = FigureCanvas(self.figure) self.canvas.set_size_request(200, 200) #tamaño mínimo del widget self.add_filter(ff_jws) self.set_select_multiple(True) if current_folder: self.set_current_folder(current_folder) self.set_preview_widget(self.canvas) self.connect("selection-changed", self._update_preview_cb) self.show_all() def _update_preview_cb(self, widget): input_fn = self.get_preview_filename() error = True if input_fn is not None: results = jwslib.read_file(input_fn) if results[0] == jwslib.JWS_ERROR_SUCCESS: header = results[1] channels = results[2] if len(channels) > 0: error = False if not error: xdata = arange( header.x_for_first_point, #start header.x_for_last_point + header.x_increment, #end+incr. header.x_increment) #increment ellipticity = array(channels[0], float32) self.figure.clear() p = self.figure.add_subplot(111) p.plot(xdata, ellipticity) self.canvas.draw() self.set_preview_widget_active(not error)
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
class JwsFileChooserDialog(gtk.FileChooserDialog): def __init__(self, parent, current_folder=None, title=_("Open spectra...")): gtk.FileChooserDialog.__init__( self, title=title, parent=parent, action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_ADD, gtk.RESPONSE_OK), ) self.figure = Figure(figsize=(5, 4)) self.canvas = FigureCanvas(self.figure) self.canvas.set_size_request(200, 200) # tamaño mínimo del widget self.add_filter(ff_jws) self.set_select_multiple(True) if current_folder: self.set_current_folder(current_folder) self.set_preview_widget(self.canvas) self.connect("selection-changed", self._update_preview_cb) self.show_all() def _update_preview_cb(self, widget): input_fn = self.get_preview_filename() error = True if input_fn is not None: results = jwslib.read_file(input_fn) if results[0] == jwslib.JWS_ERROR_SUCCESS: header = results[1] channels = results[2] if len(channels) > 0: error = False if not error: xdata = arange( header.x_for_first_point, # start header.x_for_last_point + header.x_increment, # end+incr. header.x_increment, ) # increment ellipticity = array(channels[0], float32) self.figure.clear() p = self.figure.add_subplot(111) p.plot(xdata, ellipticity) self.canvas.draw() self.set_preview_widget_active(not error)
def __init__(self, label): self.plots = dict() gtk.Frame.__init__(self) self.set_label(label) self.fig = Figure(figsize=(6, 4)) self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea #self.add(self.canvas) vbox = gtk.VBox() vbox.pack_start(self.canvas) toolbar = NavigationToolbar(self.canvas, self) vbox.pack_start(toolbar, False, False) self.add(vbox)
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)
def connect(self): logger.debug("Opening matplotlib session.") self.figure = Figure(dpi=100, facecolor="white") # figsize=(5,4), dpi=100) self.canvas = FigureCanvas(self.figure) self.canvas.show() self.line_cache.clear() self.layer_to_axes.clear() self.axes_to_layer.clear() backend.Plotter.connect(self) logger.debug("Init finished")
def clearGraphData(self): try: if self.canvas: self.graphBox.remove(self.canvas) except: pass if self.fig != None: self.fig.clear() self.fig = Figure(figsize=(5, 4), dpi=100) if self.canvas is not None: self.canvas.destroy() self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
def clearGraphData(self): try: if self.canvas: self.graphBox.remove(self.canvas) except: pass if self.fig != None: self.fig.clear() self.fig = Figure(figsize=(5,4), dpi=100) if self.canvas is not None: self.canvas.destroy() self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
def __init__(self, title, parent, filename, tmpn, type): # create matplotlib figure self.figure = Figure() self.canvas = FigureCanvas(self.figure) self.mp = ManipulateXYData(filename, type, self.figure, self, tmpn=tmpn) # create GTK dialog self.dialog = gtk.Dialog(title=title, parent=parent, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) self.dialog.set_default_size(500, 400) self.vBox = self.dialog.vbox # setup matplotlib events self.canvas.mpl_connect('button_press_event', self.mp.on_click) self.canvas.mpl_connect('button_release_event', self.mp.on_release) # create buttons self.buttonBox = gtk.HBox(homogeneous=True, spacing=5) self.saveButton = gtk.Button(label="Save and Use", stock=gtk.STOCK_SAVE) self.useButton = gtk.Button(label="Use") self.revertButton = gtk.Button(label="Revert") self.cancelButton = gtk.Button(label="Cancel") # pack buttons self.buttonBox.pack_start(self.saveButton, expand=False) self.buttonBox.pack_start(self.useButton, expand=False) self.buttonBox.pack_start(self.revertButton, expand=False) self.buttonBox.pack_end(self.cancelButton, expand=False) # connect buttons self.use = False self.save = False self.saveButton.connect("clicked", self.saveHandler) self.useButton.connect("clicked", self.useHandler) self.revertButton.connect("clicked", self.revertHandler) self.cancelButton.connect("clicked", self.cancelHandler) # pack and show dialog self.vBox.pack_start(self.canvas, expand=True) self.vBox.pack_start(gtk.HSeparator(), expand=False) self.vBox.pack_end(self.buttonBox, expand=False) self.dialog.show_all()
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)
def __init__(self, module, mainWindow, preferredWidth, preferredHeight, startWithImage=True): """ Constructor for a Mat Plot Lib Plotter. module - the module using this plotter mainWindow - the MainWindow displaying this plotter preferredWidth - the default width of the plotter preferredHeight - the default height of the plotter startWithImage - a boolean, that if true will display the module's baseimage at first, and switch to the matplotlib plotter when setBaseImageVisible(False) or drawFigure() is called. """ # call the superclass constructor Plotter.__init__(self, module, mainWindow) self.preferredWidth = preferredWidth self.preferredHeight = preferredHeight self.imageVisible = startWithImage path = mainWindow.getPath() if (self.module.baseimage): self.imageFile = self.module.directory + os.sep + self.module.baseimage else: self.imageFile = path + os.sep + "img" + os.sep + "seatree.jpg" self.figure = matplotlib.figure.Figure() self.axis = self.figure.add_subplot(111) self.canvas = FigureCanvas(self.figure) self.bgColor = "white" self.colorMap = matplotlib.cm.Spectral self.evenAspectRatio = True self.climMin = None self.climMax = None self.image = None self.contourLines = False self.contourFills = False self.colorBarOrientation = VERTICAL self.gui = mplSettingsPanel.MPLSettingsPanel(self)
def _create_widgets(self): def create_label(text): label = gtk.Label(text) label.show() return label self.smoothing_list = gtk.ListStore(str) smoothing_types = ("Mean-movement", "Savitsky-Golay", _("No smoothing")) for smt in smoothing_types: self.smoothing_list.append([smt]) cell = gtk.CellRendererText() self.smoothing_combo = gtk.ComboBox(self.smoothing_list) self.smoothing_combo.pack_start(cell, True) self.smoothing_combo.add_attribute(cell, 'text', 0) self.smoothing_combo.show() self.m_spinner = gtk.SpinButton() self.m_spinner.set_range(5, 25) self.m_spinner.set_increments(1,5) self.m_spinner.show() self.p_spinner = gtk.SpinButton() self.p_spinner.set_range(1,6) self.p_spinner.set_increments(1,1) self.p_spinner.show() sc_hbox = gtk.HBox() sc_hbox.pack_start(create_label(_("Smoothing type:")), False, False, 0) sc_hbox.pack_end(self.smoothing_combo, False, True, 0) sc_hbox.show() sm_hbox = gtk.HBox() sm_hbox.pack_start(create_label(_("Smoothing level(m):")), False, False, 0) sm_hbox.pack_end(self.m_spinner, False, False, 0) sm_hbox.show() sp_hbox = gtk.HBox() sp_hbox.pack_start(create_label(_("S-G filter order (p):")), False, False, 0) sp_hbox.pack_end(self.p_spinner, False, False, 0) sp_hbox.show() self.sp_hbox = sp_hbox self.figure = Figure(figsize=(5,4)) self.canvas = FigureCanvas(self.figure) self.canvas.show() self.vbox.pack_start(sc_hbox, False, False, 0) self.vbox.pack_start(sm_hbox, False, False, 0) self.vbox.pack_start(sp_hbox, False, False, 0) self.vbox.pack_start(self.canvas, True, True, 0) self.set_default_size(400,400)
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 __init__(self): """Initialize an instance of the RAMSTKPlot.""" # Initialize private dictionary attributes. # Initialize private list attributes. self._lst_max = [] self._lst_min = [0.0] # Initialize private scalar attributes. # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self.figure = Figure() self.plot = FigureCanvas(self.figure) self.axis = self.figure.add_subplot(111)
def __init__(self, parent, current_folder=None, title=_("Open spectra...")): gtk.FileChooserDialog.__init__( self, title=title, parent=parent, action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_ADD, gtk.RESPONSE_OK), ) self.figure = Figure(figsize=(5, 4)) self.canvas = FigureCanvas(self.figure) self.canvas.set_size_request(200, 200) # tamaño mínimo del widget self.add_filter(ff_jws) self.set_select_multiple(True) if current_folder: self.set_current_folder(current_folder) self.set_preview_widget(self.canvas) self.connect("selection-changed", self._update_preview_cb) self.show_all()
def __init__(self): gtk.Window.__init__(self) self.connect('destroy', lambda win: gtk.main_quit()) self.set_title('GtkListStore demo') self.set_border_width(8) vbox = gtk.VBox(FALSE, 8) self.add(vbox) label = gtk.Label('Double click a row to plot the data') vbox.pack_start(label, FALSE, FALSE) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) vbox.pack_start(sw, True, True) model = self.create_model() self.treeview = gtk.TreeView(model) self.treeview.set_rules_hint(TRUE) # matplotlib stuff fig = Figure(figsize=(6,4)) self.canvas = FigureCanvas(fig) # a gtk.DrawingArea vbox.pack_start(self.canvas, False, False) ax = fig.add_subplot(111) self.line, = ax.plot(self.data[0,:], 'go') # plot the first row self.treeview.connect('row-activated', self.plot_row) sw.add(self.treeview) self.add_columns() self.set_default_size(600, 600) self.add_events(gdk.BUTTON_PRESS_MASK | gdk.KEY_PRESS_MASK| gdk.KEY_RELEASE_MASK)
def updt_plot(GUI): GUI.axis.lines.pop(0) GUI.axis.lines.pop(0) #GUI.axis.lines.pop(0) #GUI.axis.lines.pop(0) #GUI.axis.lines.pop(0) GUI.axis.plot(GUI.sig_x, 'b', label='tip') GUI.axis.plot(GUI.sig_y, 'r', label='tilt') GUI.axis.plot(GUI.sig_f, 'g', label='focus') #GUI.axis.lines.pop(0) #GUI.axis.plot(GUI.ave_a1, 'g', label='45a') #GUI.axis.plot(GUI.ave_a2, 'y', label='90a') GUI.canvas = FigureCanvasGTK(GUI.figure) GUI.canvas.show() GUI.table.attach(GUI.canvas, 0, 4, 0, 9)
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
def clearGraphData(self): try: try: if self.canvas: self.graphBox.remove(self.canvas) except: pass if self.fig is not None: self.fig.clear() self.fig = Figure(figsize=(5,4), dpi=100) if self.canvas is not None: self.canvas.destroy() self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea except: err = traceback.extract_tb(sys.exc_info()[2])[-1] print _("Error:")+" "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1]) raise
def clearGraphData(self): try: try: if self.canvas: self.graphBox.remove(self.canvas) except: pass if self.fig != None: self.fig.clear() self.fig = Figure(figsize=(5,4), dpi=100) if self.canvas is not None: self.canvas.destroy() self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea except: err = traceback.extract_tb(sys.exc_info()[2])[-1] print _("Error:")+" "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1]) raise
def updt_plot(GUI): GUI.axis.lines.pop(0) GUI.axis.lines.pop(0) #GUI.axis.lines.pop(0) #GUI.axis.lines.pop(0) #GUI.axis.lines.pop(0) GUI.axis.plot(GUI.sig_x, 'b', label='Oblique Astig') GUI.axis.plot(GUI.sig_y, 'r', label='Right Astig') GUI.axis.legend(loc=0) #GUI.axis.plot(GUI.sig_f, 'g', label='focus') #GUI.axis.lines.pop(0) #GUI.axis.plot(GUI.ave_a1, 'g', label='45a') #GUI.axis.plot(GUI.ave_a2, 'y', label='90a') GUI.canvas = FigureCanvasGTK(GUI.figure) GUI.canvas.show() GUI.table.attach(GUI.canvas, 0, 4, 0, 9)
def __init__(self, _components = None, _data=None): self.components = _components self.data = _data gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL) self.set_default_size(700,500) self.set_title("Choose components to use...") self.connect("delete_event", self.delete_event) self.connect("destroy", self.delete_event) self.vbox = gtk.VBox() self.add(self.vbox) self.f = Figure(figsize=(5,4), dpi=100, subplotpars=SubplotParams(left=0.06, top=0.95, right=0.97, bottom=0.1)) self.setupSubplots() self.plotAll() self.canvas = FigureCanvas(self.f) self.canvas.mpl_connect('button_press_event', self.cb_canvas) self.vbox.pack_start(self.canvas) self.toolbar = NavigationToolbar( self.canvas, self.window ) self.vbox.pack_start(self.toolbar, False, False) self.show_all()
def __init__(self, parent, current_folder=None, title=_("Open spectra...")): gtk.FileChooserDialog.__init__( self, title=title, parent=parent, action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_ADD, gtk.RESPONSE_OK)) self.figure = Figure(figsize=(5, 4)) self.canvas = FigureCanvas(self.figure) self.canvas.set_size_request(200, 200) #tamaño mínimo del widget self.add_filter(ff_jws) self.set_select_multiple(True) if current_folder: self.set_current_folder(current_folder) self.set_preview_widget(self.canvas) self.connect("selection-changed", self._update_preview_cb) self.show_all()