Example #1
0
 def add_image(self, plot):
     """
     Add Image
     """
     self.plots[plot.name] = plot
     # init graph
     self.graph = Graph()
     # add plot
     self.graph.add(plot)
     # add axes
     if self.dimension == 1:
         self.xaxis_label = '\\rm{x} '
         self.xaxis_unit = ''
         self.yaxis_label = '\\rm{y} '
         self.yaxis_unit = ''
     # draw
     # message
     status_type = 'progress'
     msg = 'Plotting...'
     self._status_info(msg, status_type)
     status_type = 'stop'
     self.graph.render(self)
     self.subplot.figure.canvas.resizing = False
     if self.dimension < 3:
         self.graph.render(self)
         self.subplot.figure.canvas.draw()
     elif FONT_VARIANT:
         self.subplot.figure.canvas.draw()
     msg = 'Plotting Completed.'
     self._status_info(msg, status_type)
Example #2
0
 def show_plot(self, plot):
     """
     Show the plot
     """
     _yaxis, _yunit = plot.get_yaxis()
     _xaxis, _xunit = plot.get_xaxis()
     self.data = plot
     self.plots[plot.name] = plot
     # Axis scales
     if plot.xtransform != None:
         self.xLabel = plot.xtransform
     if plot.ytransform != None:
         self.yLabel = plot.ytransform
     # Init graph
     self.graph = Graph()
     # Add plot: Handles both 1D and 2D
     self.graph.add(self.data)
     self.canvas.set_resizing(False)
     if self.data.__class__.__name__ == 'Data2D':
         self.data2D = plot
     elif self.data.__class__.__name__ == 'Data1D':
         self._onEVT_FUNC_PROPERTY(show=False)
     # Axes
     self.graph.xaxis(_xaxis, _xunit)
     self.graph.yaxis(_yaxis, _yunit)
     self.xaxis(_xaxis, _xunit)
     self.yaxis(_yaxis, _yunit)
     self.set_xscale(self.xscale)
     self.set_yscale(self.yscale)
     self.graph.render(self)
Example #3
0
    def __init__(self, parent, axes=[], id=-1, color=None, dpi=None, **kwargs):
        """
        """
        PlotPanel.__init__(self,
                           parent,
                           id=id,
                           xtransform='x',
                           ytransform='y',
                           color=color,
                           dpi=dpi,
                           size=(_STATICBOX_WIDTH, PANEL_SIZE - 100),
                           **kwargs)

        # Keep track of the parent Frame
        self.parent = parent
        self.window_name = "Scattering Length Density Profile"
        self.window_caption = self.window_name
        self.prevXtrans = "x"
        self.prevYtrans = "y"
        self.viewModel = "--"
        # Internal list of plottable names (because graph
        # doesn't have a dictionary of handles for the plottables)
        self.plots = {}
        self.graph = Graph()
        self.axes_label = []
        for idx in range(0, len(axes)):
            self.axes_label.append(axes[idx])
        self.xaxis_label = ''
        self.xaxis_unit = ''
        self.yaxis_label = ''
        self.yaxis_unit = ''
        self.resizing = True
        self.xcolor = 'black'
        self.ycolor = 'black'
Example #4
0
def sample_graph():
    # Construct a simple graph

    T1 = Text(text='text example 1', xpos=0.2, ypos=0.2)
    T2 = Text(text='text example 2', xpos=0.5, ypos=0.5)
    T3 = Text(text=r'$\chi^2=1.2$', xpos=0.8, ypos=0.8)

    graph = Graph()
    graph.title('Test Text Class')
    graph.add(T1)
    graph.add(T2)
    graph.add(T3)
    return graph
Example #5
0
    def __init__(self,
                 parent,
                 id=-1,
                 data2d=None,
                 color=None,
                 dpi=None,
                 style=wx.NO_FULL_REPAINT_ON_RESIZE,
                 **kwargs):
        """
        Initialize the panel
        """
        ModelPanel1D.__init__(self, parent, id=id, style=style, **kwargs)
        self.parent = parent
        ## Reference to the parent window
        if hasattr(parent, "parent"):
            self.parent = self.parent.parent
        ## Dictionary containing Plottables
        self.plots = {}
        ## Save reference of the current plotted
        self.data2D = data2d
        ## Unique ID (from gui_manager)
        self.uid = None
        ## Action IDs for internal call-backs
        self.action_ids = {}
        ## Create Artist and bind it
        self.connect = BindArtist(self.subplot.figure)
        ## Beam stop
        self.beamstop_radius = DEFAULT_BEAM
        ## to set the order of lines drawn first.
        self.slicer_z = 5
        ## Reference to the current slicer
        self.slicer = None
        ## event to send slicer info
        self.Bind(EVT_INTERNAL, self._onEVT_INTERNAL)

        self.axes_frozen = False
        ## panel that contains result from slicer motion (ex: Boxsum info)
        self.panel_slicer = None
        self.title_label = None
        self.title_font = None
        self.title_color = 'black'
        ## Graph
        self.graph = Graph()
        self.graph.xaxis("\\rm{Q}", 'A^{-1}')
        self.graph.yaxis("\\rm{Intensity} ", "cm^{-1}")
        self.graph.render(self)
        ## store default value of zmin and zmax
        self.default_zmin_ctl = self.zmin_2D
        self.default_zmax_ctl = self.zmax_2D
Example #6
0
    def add_image(self, plot):
        """
        Add Image
        """
        self.content = ''
        self.textList = []
        self.plots = {}
        self.clear()
        self.point = plot
        try:
            self.figure.delaxes(self.figure.axes[0])
            self.subplot = self.figure.add_subplot(111)
            #self.figure.delaxes(self.figure.axes[1])
        except:
            pass
        try:
            name = plot.name
        except:
            name = plot.filename
        self.plots[name] = plot

        #init graph
        self.graph = Graph()

        #add plot
        self.graph.add(plot)
        #draw
        self.graph.render(self)

        try:
            self.figure.delaxes(self.figure.axes[1])
        except:
            pass
        self.subplot.figure.canvas.resizing = False
        self.subplot.tick_params(axis='both', labelsize=9)
        # Draw zero axis lines
        self.subplot.axhline(linewidth=1, color='r')
        self.subplot.axvline(linewidth=1, color='r')

        self.erase_legend()
        try:
            # mpl >= 1.1.0
            self.figure.tight_layout()
        except:
            self.figure.subplots_adjust(left=0.1, bottom=0.1)
        self.subplot.figure.canvas.draw()
Example #7
0
def sample_graph():
    # Construct a simple graph
    x = numpy.linspace(0, 2.0, 50)
    y = numpy.sin(2 * numpy.pi * x * 2.8)
    dy = numpy.sqrt(100 * numpy.abs(y)) / 100

    data = Data1D(x, y, dy=dy)
    data.xaxis('distance', 'm')
    data.yaxis('time', 's')

    graph = Graph()

    graph.add(data)
    graph.add(Theory1D(x, y, dy=dy))

    graph.title('Test Copy and Print Image')
    return graph
Example #8
0
    def __init__(self,
                 parent,
                 id=-1,
                 dimension=2,
                 color=None,
                 dpi=None,
                 **kwargs):
        """
        """
        PlotPanel.__init__(self, parent, id=id, color=color, dpi=dpi, **kwargs)

        # Keep track of the parent Frame
        self.parent = parent
        # Internal list of plottable names (because graph
        # doesn't have a dictionary of handles for the plottables)
        self.dimension = dimension
        self.plots = {}
        self.graph = Graph()
        # add axis labels
        self.graph.xaxis('\\rm{x} ', '')
        self.graph.yaxis('\\rm{y} ', '')
Example #9
0
def sample_graph():
    # Construct a simple graph
    if False:
        x = numpy.array([1,2,3,4,5,6],'d')
        y = numpy.array([4,5,26,5,4,-1],'d')
        dy = numpy.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3])
    else:
        x = numpy.linspace(0,2.0, 50)
        y = numpy.sin(2*numpy.pi*x*2.8)
        dy = numpy.sqrt(100*numpy.abs(y))/100

    from sas.plottools.plottables import Data1D, Theory1D, Chisq , Graph
    data = Data1D(x,y,dy=dy)
    data.xaxis('distance', 'm')
    data.yaxis('time', 's')
    graph = Graph()
    graph.title('Walking Results')
    graph.add(data)
    graph.add( Theory1D(x,y,dy=dy))
    graph.add( Chisq( 1.0 ) )
    return graph
Example #10
0
    def __init__(self, d_min, d_max, parent, id= -1, color=None, \
                 dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
        """
        Initialization. The parameters added to PlotPanel are:

        :param d_min: Minimum value of D_max to explore
        :param d_max: Maximum value of D_max to explore

        """
        PlotPanel.__init__(self, parent, id=id, style=style, **kwargs)

        self.parent = parent
        self.min = d_min
        self.max = d_max
        self.npts = DEFAULT_NPTS

        step = (self.max - self.min) / (self.npts - 1)
        self.x = numpy.arange(self.min, self.max + step * 0.01, step)
        dx = numpy.zeros(len(self.x))
        y = numpy.ones(len(self.x))
        dy = numpy.zeros(len(self.x))

        # Plot area
        self.plot = Model1D(self.x, y=y, dy=dy)
        self.plot.name = DEFAULT_OUTPUT
        self.plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM

        # Graph
        self.graph = Graph()
        self.graph.xaxis("\\rm{D_{max}}", 'A')
        self.graph.yaxis("\\rm{%s}" % DEFAULT_OUTPUT, "")
        self.graph.add(self.plot)
        self.graph.render(self)

        self.toolbar.DeleteToolByPos(0)
        self.toolbar.DeleteToolByPos(8)
        self.toolbar.Realize()