def on_savedata (self): """ Handles the user requesting that the data of the function \ is to be saved. """ import os dlg = FileDialog(parent = self.control, title = 'Export function data', default_directory = os.getcwd(), default_filename = "", wildcard = '*.csv', action = 'save as') if dlg.open() == OK: path = dlg.path print "Saving data to", path, "..." try: factory = self.factory plotitem = factory.plotitem x_values = getattr(self.object, plotitem.index) y_values = getattr(self.object, plotitem.value_list) except: print "Error saving!" raise print "Plot saved." return
def on_savedata(self): """ Handles the user requesting that the data of the function is to be saved. """ import os dlg = FileDialog(parent=self.control, title='Export function data', default_directory=os.getcwd(), default_filename="", wildcard='*.csv', action='save as') if dlg.open() == OK: path = dlg.path print "Saving data to", path, "..." try: # factory = self.factory # plotitem = factory.plotitem # x_values = getattr(self.object, plotitem.index) # y_values = getattr(self.object, plotitem.value) x_values = self.value.xdata y_values = self.value.ydata savetxt(path, vstack((x_values, y_values)).transpose()) except: print "Error saving!" raise print "Plot saved." return
def on_savefig(self): """ Handles the user requesting that the image of the function is to be saved. """ import os dlg = FileDialog(parent=self.control, title='Save as image', default_directory=os.getcwd(), default_filename="", wildcard=WILDCARD, action='save as') if dlg.open() == OK: path = dlg.path print "Saving plot to", path, "..." try: # Now we create a canvas of the appropriate size and ask it to render # our component. (If we wanted to display this plot in a window, we # would not need to create the graphics context ourselves; it would be # created for us by the window.) size = (650, 400) gc = GraphicsContext(size) self.plot_container.draw(gc) gc.save(path) except: print "Error saving!" raise print "Plot saved." return
def on_savedata(self): """ Handles the user requesting that the data of the function is to be saved. """ import os dlg = FileDialog(parent=self.control, title='Export function data', default_directory=os.getcwd(), default_filename="", wildcard='*.csv', action='save as') if dlg.open() == OK: path = dlg.path print "Saving data to", path, "..." try: vectors = [] x_values = self.value.xdata y_values = self.value.ydata #savetxt( path, vstack( (x_values, y_values[:,0], y_values[:,1], y_values[:,2]) ).transpose() ) print 'y_values', y_values y_values_tr = y_values.transpose() for vector in y_values_tr[:]: vectors.append(vector) savetxt(path, vstack((x_values, vectors)).transpose()) except: print "Error saving!" raise print "Plot saved." return
def on_savefig(self): """ Handles the user requesting that the image of the function is to be saved. """ import os dlg = FileDialog( parent=self.control, title="Save as image", default_directory=os.getcwd(), default_filename="", wildcard=WILDCARD, action="save as", ) if dlg.open() == OK: path = dlg.path print "Saving plot to", path, "..." try: # Now we create a canvas of the appropriate size and ask it to render # our component. (If we wanted to display this plot in a window, we # would not need to create the graphics context ourselves; it would be # created for us by the window.) size = (650, 400) gc = GraphicsContext(size) self.plot_container.draw(gc) gc.save(path) except: print "Error saving!" raise print "Plot saved." return
def on_savedata(self): """ Handles the user requesting that the data of the function is to be saved. """ import os dlg = FileDialog( parent=self.control, title="Export function data", default_directory=os.getcwd(), default_filename="", wildcard="*.csv", action="save as", ) if dlg.open() == OK: path = dlg.path print "Saving data to", path, "..." try: vectors = [] x_values = self.value.xdata y_values = self.value.ydata # savetxt( path, vstack( (x_values, y_values[:,0], y_values[:,1], y_values[:,2]) ).transpose() ) print "y_values", y_values y_values_tr = y_values.transpose() for vector in y_values_tr[:]: vectors.append(vector) savetxt(path, vstack((x_values, vectors)).transpose()) except: print "Error saving!" raise print "Plot saved." return
def on_savefig ( self ): """ Handles the user requesting that the image of the function is to be saved. """ import os dlg = FileDialog(parent = self.control, title = 'Save as image', default_directory=os.getcwd(), default_filename="", wildcard=WILDCARD, action='save as') if dlg.open() == OK: path = dlg.path print "Saving plot to", path, "..." try: """ Now we create a canvas of the appropriate size and ask it to render our component. (If we wanted to display this plot in a window, we would not need to create the graphics context ourselves; it would be created for us by the window.) """ # self._plot.bounds = [500,300] # self._plot.padding = 50 # plot_gc = PlotGraphicsContext(self._plot.outer_bounds) # plot_gc.render_component(self._plot) #self._plot_container.outer_bounds = list((800,600)) # plot_gc = PlotGraphicsContext((400,300), dpi=72.0) # plot_gc.render_component(self._plot_container) self.lplot.bounds = [500,300] self.lplot.padding = 50 win_size = self.lplot.outer_bounds plot_gc = PlotGraphicsContext(win_size) # Have the plot component into it plot_gc.render_component(self.lplot) # Finally, we tell the graphics context # to save itself to disk as an image. plot_gc.save(path) except: print "Error saving!" raise print "Plot saved." return
def on_savefig(self): """ Handles the user requesting that the image of the function is to be saved. """ import os dlg = FileDialog(parent=self.control, title='Save as image', default_directory=os.getcwd(), default_filename="", wildcard=WILDCARD, action='save as') if dlg.open() == OK: path = dlg.path print "Saving plot to", path, "..." try: """ Now we create a canvas of the appropriate size and ask it to render our component. (If we wanted to display this plot in a window, we would not need to create the graphics context ourselves; it would be created for us by the window.) """ # self._plot.bounds = [500,300] # self._plot.padding = 50 # plot_gc = PlotGraphicsContext(self._plot.outer_bounds) # plot_gc.render_component(self._plot) #self._plot_container.outer_bounds = list((800,600)) # plot_gc = PlotGraphicsContext((400,300), dpi=72.0) # plot_gc.render_component(self._plot_container) self.lplot.bounds = [500, 300] self.lplot.padding = 50 win_size = self.lplot.outer_bounds plot_gc = PlotGraphicsContext(win_size) # Have the plot component into it plot_gc.render_component(self.lplot) # Finally, we tell the graphics context # to save itself to disk as an image. plot_gc.save(path) except: print "Error saving!" raise print "Plot saved." return