Example #1
0
    def _refresh_container(self):
        ''' rebuild the container for the current data
        '''
        broadcaster = BroadcasterTool()

        mfn_line = self.value
        #   print self.panel.GetSize()
        adapter = self.adapter
        if adapter.var_x != '':
            # Get the x-label text from the object's trait var_x
            label_x = getattr(self.object, adapter.var_x)
        else:
            # Get the x-label from the adapter
            label_x = adapter.label_x

        if adapter.var_y != '':
            label_y = getattr(self.object, adapter.var_y)
        else:
            label_y = adapter.label_y

        index = ArrayDataSource(mfn_line.xdata)
        y = ArrayDataSource(mfn_line.ydata, sort_order="none")

        index_range = DataRange1D()
        index_range.add(index)
        index_mapper = LinearMapper(range=index_range)

        value_range = DataRange1D(low_setting=0.0)
        value_range.add(y)
        value_mapper = LinearMapper(range=value_range)

        styles_m = adapter.line_style.values()
        line_style = styles_m[0]
        line_color = adapter.line_color[0]

        line_plot = self.lplot = LinePlot(index=index,
                                          value=y,
                                          index_mapper=index_mapper,
                                          value_mapper=value_mapper,
                                          color=line_color,
                                          width=25,
                                          edge_color='blue',
                                          linestyle=line_style,
                                          border_visible=False)

        add_default_grids(line_plot)
        add_default_axes(line_plot, vtitle="Y", htitle="X")

        self.plot_container.add(line_plot)
        line_plot.tools.append(PanTool(line_plot))
        line_plot.overlays.append(ZoomTool(line_plot))
Example #2
0
    def _refresh_container( self ):
        ''' rebuild the container for the current data
        '''
        broadcaster = BroadcasterTool()
    
        mfn_line = self.value
     #   print self.panel.GetSize()
        adapter = self.adapter
        if adapter.var_x != '':
            # Get the x-label text from the object's trait var_x          
            label_x = getattr( self.object, adapter.var_x )
        else:
            # Get the x-label from the adapter          
            label_x = adapter.label_x
            
        if adapter.var_y  != '':
            label_y = getattr( self.object, adapter.var_y )
        else:
            label_y = adapter.label_y

        index = ArrayDataSource(mfn_line.xdata)
        y = ArrayDataSource(mfn_line.ydata, sort_order="none")
        
        index_range = DataRange1D()
        index_range.add(index)
        index_mapper = LinearMapper(range=index_range)
    
        value_range = DataRange1D(  low_setting = 0.0  )
        value_range.add(y)
        value_mapper = LinearMapper(range=value_range)

        styles_m =  adapter.line_style.values()
        line_style = styles_m[0]
        line_color = adapter.line_color[0]
  

        line_plot = self.lplot = LinePlot(index = index, value = y,
                                    index_mapper = index_mapper,
                                    value_mapper = value_mapper,
                                    color = line_color,
                                    width = 25,
                                    edge_color = 'blue',
                                    linestyle = line_style,      
                                    border_visible = False)

        add_default_grids(line_plot)
        add_default_axes(line_plot, vtitle="Y", htitle="X")

        self.plot_container.add(line_plot)
        line_plot.tools.append(PanTool(line_plot))
        line_plot.overlays.append(ZoomTool(line_plot))
Example #3
0
    def _refresh_container(self):
        ''' rebuild the container for the current data
        '''
        broadcaster = BroadcasterTool()

        mfn_line = self.value
        ydata = transpose(mfn_line.ydata)

        adapter = self.adapter
        if adapter.var_x != '':
            # Get the x-label text from the object's trait var_x
            label_x = getattr(self.object, adapter.var_x)
        else:
            # Get the x-label from the adapter
            label_x = adapter.label_x

        if adapter.var_y != '':
            label_y = getattr(self.object, adapter.var_y)
        else:
            label_y = adapter.label_y

        index = ArrayDataSource(mfn_line.xdata)
        index_range = DataRange1D()
        index_range.add(index)
        index_mapper = LinearMapper(range=index_range)

        value_range = DataRange1D(low_setting=0.0)

        colors = []
        colors = adapter.line_color  #self.line_color_chaco.values()

        styles = []
        styles = adapter.line_style  #self.line_style_chaco.values()

        s_item = styles.items()

        color_chaco = []
        style_chaco = []
        c_index = 0  # loop for colors
        s_index = 0  # loop for styles
        i = 0  # for colors and styles
        plots = {}  # for legend

        pd = ArrayPlotData(index=mfn_line.xdata)
        self.splot = Plot(pd)

        for vector in ydata[:]:

            if len(colors) == c_index:
                c_index = 0
            if len(styles) == s_index:
                s_index = 0

            style_name = s_item[s_index][0]
            color_chaco.append(colors[c_index])
            style_chaco.append(style_name)
            c_index = c_index + 1
            s_index = s_index + 1

            y = ArrayDataSource(vector, sort_order="none")

            value_range.add(y)
            value_mapper = LinearMapper(range=value_range)

            self.line_plot = LinePlot(index=index,
                                      value=y,
                                      index_mapper=index_mapper,
                                      value_mapper=value_mapper,
                                      color=color_chaco[i],
                                      line_width=adapter.linewidth,
                                      edge_color='blue',
                                      border_visible=False,
                                      line_style=style_chaco[i])

            add_default_grids(self.line_plot)
            add_default_axes(self.line_plot, vtitle=label_y, htitle=label_x)

            self.plot_container.add(self.line_plot)
            #            pan = PanTool(line_plot)
            #            zoom = SimpleZoom(line_plot, tool_mode="box", always_on=False)
            #            broadcaster.tools.append(pan)
            #            broadcaster.tools.append(zoom)

            # Add the traits inspector tool to the container
            #
            #           self.plot_container.tools.append(TraitsTool( self.plot_container ))

            self.line_plot.tools.append(PanTool(self.line_plot))
            self.line_plot.overlays.append(ZoomTool(self.line_plot))

            # Legend
            lgnd = adapter.legend_labels[i]
            plots[lgnd] = self.line_plot

            # change the color of the curves
            i = i + 1

        legend = Legend(component=self.plot_container, padding=10, align="ul")
        legend.tools.append(LegendTool(legend, drag_button="right"))
        self.plot_container.overlays.append(legend)

        # Set the list of plots on the legend
        legend.plots = plots

        # Add the title at the top
        self.plot_container.overlays.append(
            PlotLabel(adapter.title,
                      component=self.plot_container,
                      font="swiss 16",
                      overlay_position="top"))
    def _refresh_container(self):
        """ rebuild the container for the current data
        """
        broadcaster = BroadcasterTool()

        mfn_line = self.value
        ydata = transpose(mfn_line.ydata)

        adapter = self.adapter
        if adapter.var_x != "":
            # Get the x-label text from the object's trait var_x
            label_x = getattr(self.object, adapter.var_x)
        else:
            # Get the x-label from the adapter
            label_x = adapter.label_x

        if adapter.var_y != "":
            label_y = getattr(self.object, adapter.var_y)
        else:
            label_y = adapter.label_y

        index = ArrayDataSource(mfn_line.xdata)
        index_range = DataRange1D()
        index_range.add(index)
        index_mapper = LinearMapper(range=index_range)

        value_range = DataRange1D(low_setting=0.0)

        colors = []
        colors = adapter.line_color  # self.line_color_chaco.values()

        styles = []
        styles = adapter.line_style  # self.line_style_chaco.values()

        s_item = styles.items()

        color_chaco = []
        style_chaco = []
        c_index = 0  # loop for colors
        s_index = 0  # loop for styles
        i = 0  # for colors and styles
        plots = {}  # for legend

        pd = ArrayPlotData(index=mfn_line.xdata)
        self.splot = Plot(pd)

        for vector in ydata[:]:

            if len(colors) == c_index:
                c_index = 0
            if len(styles) == s_index:
                s_index = 0

            style_name = s_item[s_index][0]
            color_chaco.append(colors[c_index])
            style_chaco.append(style_name)
            c_index = c_index + 1
            s_index = s_index + 1

            y = ArrayDataSource(vector, sort_order="none")

            value_range.add(y)
            value_mapper = LinearMapper(range=value_range)

            self.line_plot = LinePlot(
                index=index,
                value=y,
                index_mapper=index_mapper,
                value_mapper=value_mapper,
                color=color_chaco[i],
                line_width=adapter.linewidth,
                edge_color="blue",
                border_visible=False,
                line_style=style_chaco[i],
            )

            add_default_grids(self.line_plot)
            add_default_axes(self.line_plot, vtitle=label_y, htitle=label_x)

            self.plot_container.add(self.line_plot)
            #            pan = PanTool(line_plot)
            #            zoom = SimpleZoom(line_plot, tool_mode="box", always_on=False)
            #            broadcaster.tools.append(pan)
            #            broadcaster.tools.append(zoom)

            # Add the traits inspector tool to the container
            #
            #           self.plot_container.tools.append(TraitsTool( self.plot_container ))

            self.line_plot.tools.append(PanTool(self.line_plot))
            self.line_plot.overlays.append(ZoomTool(self.line_plot))

            # Legend
            lgnd = adapter.legend_labels[i]
            plots[lgnd] = self.line_plot

            # change the color of the curves
            i = i + 1

        legend = Legend(component=self.plot_container, padding=10, align="ul")
        legend.tools.append(LegendTool(legend, drag_button="right"))
        self.plot_container.overlays.append(legend)

        # Set the list of plots on the legend
        legend.plots = plots

        # Add the title at the top
        self.plot_container.overlays.append(
            PlotLabel(adapter.title, component=self.plot_container, font="swiss 16", overlay_position="top")
        )