def make_plot(self, orientation):
        # make some data points
        x = arange(3)
        x = ArrayDataSource(x, sort_order="ascending")
        y = array([2, 0, 1])

        # Plot the data
        pd = ArrayPlotData(x=x, y=y)

        plot = Plot(pd, orientation=orientation)
        line_plot = plot.plot(("x", "y"))[0]

        # Construct a fake screen space for the plots
        # otherwise would need to actually display the plots to get this
        index_mapper = LinearMapper(data_range=DataRange1D(low=0, high=2),
                                    high_pos=380,
                                    low_pos=20)
        value_mapper = LinearMapper(data_range=DataRange1D(low=0, high=2),
                                    high_pos=380,
                                    low_pos=20)
        plot.index_mapper = index_mapper
        plot.value_mapper = value_mapper
        line_plot.index_mapper = index_mapper
        line_plot.value_mapper = value_mapper

        return plot, line_plot
Beispiel #2
0
    def make_plot(self, orientation):
        # make some data points
        x = arange(3)
        x = ArrayDataSource(x, sort_order="ascending")
        y = array([2,0,1])

        # Plot the data
        pd = ArrayPlotData(x=x, y=y)

        plot = Plot(pd, orientation=orientation)
        line_plot = plot.plot(("x", "y"))[0]

        # Construct a fake screen space for the plots
        # otherwise would need to actually display the plots to get this
        index_mapper = LinearMapper(data_range=DataRange1D(low=0,high=2),
                                    high_pos=380, low_pos=20)
        value_mapper = LinearMapper(data_range=DataRange1D(low=0,high=2),
                                    high_pos=380, low_pos=20)
        plot.index_mapper = index_mapper
        plot.value_mapper = value_mapper
        line_plot.index_mapper = index_mapper
        line_plot.value_mapper = value_mapper

        return  plot, line_plot
Beispiel #3
0
    def _create_1D1_plot(self):
        index = 0
        plot0 = Plot(self.plotdata, padding=0)
        plot0.padding_left = 5
        plot0.padding_bottom = 5
        Container = OverlayPlotContainer(padding = 50, fill_padding = True, bgcolor = "lightgray", use_backbuffer=True)
        
        y1 =  range(len(self.PCAData.batchs[0].prescores))
        points = []
        for batch in self.PCAData.batchs:
                if (self.active_scores_combobox == "Post Scores"):
                    x1 = self.PCAData.batchs[index].postscores
                else:
                    x1 = self.PCAData.batchs[index].prescores

                    
                if (self.Shape == self.phenotypes[0]):
                    a = 1
                elif (self.Shape == self.phenotypes[1]):
                    a = batch.number
                elif (self.Shape == self.phenotypes[2]):    
                    a = batch.type
                else:
                    a = 0
                    

                if (self.Color == self.phenotypes[0]):
                    b = 0
                elif(self.Color == self.phenotypes[1]):
                    b = batch.number
                elif(self.Color == self.phenotypes[2]): 
                    b = batch.type  
                else:
                    b = 0
                    

                tmarker = shapes[a]   
                bcolor = self.colors[b]
                
                                        
                for i in range(len(x1)):
                    points.append((x1[i],y1[i]))
                plot0 = create_scatter_plot((x1,y1), marker = tmarker, color=getColor(bcolor))
                
                if batch.isSelected:
                    plot0.alpha = 1
                else:
                    plot0.alpha = 0.2
                    
                plot0.bgcolor = "white"
                plot0.border_visible = True
                
                if index == 0:
                    value_mapper = plot0.value_mapper
                    index_mapper = plot0.index_mapper
                    add_default_grids(plot0)
                    add_default_axes(plot0, vtitle='PCA Indices', htitle='PCA Scores')
                    plot0.index_range.tight_bounds = False
                    plot0.index_range.refresh()
                    plot0.value_range.tight_bounds = False
                    plot0.value_range.refresh()
                    plot0.tools.append(PanTool(plot0))
                    zoom = ZoomTool(plot0, tool_mode="box", always_on=False,  maintain_aspect_ratio=False)
                    plot0.overlays.append(zoom)
                    dragzoom = DragZoom(plot0, drag_button="right",  maintain_aspect_ratio=False)
                    plot0.tools.append(dragzoom)
                    
                else:   
                    plot0.value_mapper = value_mapper
                    value_mapper.range.add(plot0.value)
                    plot0.index_mapper = index_mapper
                    index_mapper.range.add(plot0.index)
 
                Container.add(plot0)
                index = index +1

        self.RightPlot = Container                                          
Beispiel #4
0
    def _create_plot(self):

        # count data
        if len(self.df) > 0:
            self.indexes = np.arange(len(self.df.date_time))
            time_ds = ArrayDataSource(self.indexes)
            vol_ds = ArrayDataSource(self.df.volumn.values, sort_order="none")
            xmapper = LinearMapper(range=DataRange1D(time_ds))
            vol_mapper = LinearMapper(range=DataRange1D(vol_ds))

            ####################################################################
            # create volumn plot
            vol_plot = BarPlot(index=time_ds, value=vol_ds,
                               index_mapper=xmapper,
                               value_mapper=vol_mapper,
                               line_color="transparent",
                               fill_color="blue",
                               bar_width=0.6,
                               antialias=False,
                               height=100,
                               resizable="h",
                               origin="bottom left",
                               bgcolor="white",
                               border_visible=True
                               )

            vol_plot.padding = 30
            vol_plot.padding_left = 40
            vol_plot.tools.append(
                PanTool(vol_plot, constrain=True, constrain_direction="x"))
            add_default_grids(vol_plot)
            add_default_axes(vol_plot)

            #print vol_plot.index_mapper.range.high
            #print vol_plot.value_mapper.range.low, vol_plot.value_mapper.range.high
            self.vol_plot = vol_plot
            self.container.add(vol_plot)

            ####################################################################
            ## Create price plot

            sorted_vals = np.vstack(
                (self.df.open, self.df.high, self.df.low, self.df.close))
            sorted_vals.sort(0)
            __bool = self.df.close.values - self.df.open.values
            self.up_boolean = __bool >= 0
            self.down_boolean = np.invert(self.up_boolean)

            pd = ArrayPlotData(
                up_index=self.indexes[self.up_boolean],
                up_min=sorted_vals[0][self.up_boolean],
                up_bar_min=sorted_vals[1][self.up_boolean],
                up_bar_max=sorted_vals[2][self.up_boolean],
                up_max=sorted_vals[3][self.up_boolean],
                down_index=self.indexes[self.down_boolean],
                down_min=sorted_vals[0][self.down_boolean],
                down_bar_min=sorted_vals[1][self.down_boolean],
                down_bar_max=sorted_vals[2][self.down_boolean],
                down_max=sorted_vals[3][self.down_boolean],
                volumn=self.df.volumn.values,
                index=self.indexes
            )

            price_plot = Plot(pd)

            up_plot = price_plot.candle_plot(
                ("up_index", "up_min", "up_bar_min", "up_bar_max", "up_max"),
                color=color_red,
                bgcolor="azure",
                bar_line_color="black",
                stem_color="black",
                end_cap=False)[0]

            down_plot = price_plot.candle_plot(
                ("down_index", "down_min", "down_bar_min",
                 "down_bar_max", "down_max"),
                color=color_green,
                bar_line_color="black",
                stem_color="black",
                end_cap=False)[0]

            price_plot.fill_padding = True
            price_plot.padding = 30
            price_plot.padding_left = 40

            price_plot.tools.append(ZoomTool(component=price_plot, tool_mode="box", zoom_factor=1.2, always_on=False))
            price_plot.tools.append(PanTool(price_plot, drag_button="left"))
            price_plot.tools.append(
                XYTool(price_plot, callback=self._update_ohlc))  # get data
            self._add_line_tool(up_plot)
            self._add_line_tool(down_plot)
            price_plot.range2d = self._compute_range2d()

            price_plot.index_mapper = vol_plot.index_mapper  # maper vol_plot and price_plot
            self.price_plot = price_plot

            self.container.add(price_plot)
Beispiel #5
0
    def _create_plot(self):

        # count data
        if len(self.df) > 0:
            self.indexes = np.arange(len(self.df.date_time))
            time_ds = ArrayDataSource(self.indexes)
            vol_ds = ArrayDataSource(self.df.volumn.values, sort_order="none")
            xmapper = LinearMapper(range=DataRange1D(time_ds))
            vol_mapper = LinearMapper(range=DataRange1D(vol_ds))

            ####################################################################
            # create volumn plot
            vol_plot = BarPlot(
                index=time_ds,
                value=vol_ds,
                index_mapper=xmapper,
                value_mapper=vol_mapper,
                line_color="transparent",
                fill_color="blue",
                bar_width=0.6,
                antialias=False,
                height=100,
                resizable="h",
                origin="bottom left",
                bgcolor="white",
                border_visible=True,
            )

            vol_plot.padding = 30
            vol_plot.padding_left = 40
            vol_plot.tools.append(PanTool(vol_plot, constrain=True, constrain_direction="x"))
            add_default_grids(vol_plot)
            add_default_axes(vol_plot)

            # print vol_plot.index_mapper.range.high
            # print vol_plot.value_mapper.range.low, vol_plot.value_mapper.range.high
            self.vol_plot = vol_plot
            self.container.add(vol_plot)

            ####################################################################
            ## Create price plot

            sorted_vals = np.vstack((self.df.open, self.df.high, self.df.low, self.df.close))
            sorted_vals.sort(0)
            __bool = self.df.close.values - self.df.open.values
            self.up_boolean = __bool >= 0
            self.down_boolean = np.invert(self.up_boolean)

            pd = ArrayPlotData(
                up_index=self.indexes[self.up_boolean],
                up_min=sorted_vals[0][self.up_boolean],
                up_bar_min=sorted_vals[1][self.up_boolean],
                up_bar_max=sorted_vals[2][self.up_boolean],
                up_max=sorted_vals[3][self.up_boolean],
                down_index=self.indexes[self.down_boolean],
                down_min=sorted_vals[0][self.down_boolean],
                down_bar_min=sorted_vals[1][self.down_boolean],
                down_bar_max=sorted_vals[2][self.down_boolean],
                down_max=sorted_vals[3][self.down_boolean],
                volumn=self.df.volumn.values,
                index=self.indexes,
            )

            price_plot = Plot(pd)

            up_plot = price_plot.candle_plot(
                ("up_index", "up_min", "up_bar_min", "up_bar_max", "up_max"),
                color=color_red,
                bgcolor="azure",
                bar_line_color="black",
                stem_color="black",
                end_cap=False,
            )[0]

            down_plot = price_plot.candle_plot(
                ("down_index", "down_min", "down_bar_min", "down_bar_max", "down_max"),
                color=color_green,
                bar_line_color="black",
                stem_color="black",
                end_cap=False,
            )[0]

            price_plot.fill_padding = True
            price_plot.padding = 30
            price_plot.padding_left = 40

            price_plot.tools.append(ZoomTool(component=price_plot, tool_mode="box", zoom_factor=1.2, always_on=False))
            price_plot.tools.append(PanTool(price_plot, drag_button="left"))
            price_plot.tools.append(XYTool(price_plot, callback=self._update_ohlc))  # get data
            self._add_line_tool(up_plot)
            self._add_line_tool(down_plot)
            price_plot.range2d = self._compute_range2d()

            price_plot.index_mapper = vol_plot.index_mapper  # maper vol_plot and price_plot
            self.price_plot = price_plot

            self.container.add(price_plot)
Beispiel #6
0
    def _create_1D1_plot(self):
        index = 0
        plot0 = Plot(self.plotdata, padding=0)
        plot0.padding_left = 5
        plot0.padding_bottom = 5
        Container = OverlayPlotContainer(padding=50,
                                         fill_padding=True,
                                         bgcolor="lightgray",
                                         use_backbuffer=True)

        y1 = range(len(self.PCAData.batchs[0].prescores))
        points = []
        for batch in self.PCAData.batchs:
            if (self.active_scores_combobox == "Post Scores"):
                x1 = self.PCAData.batchs[index].postscores
            else:
                x1 = self.PCAData.batchs[index].prescores
            '''if (self.Shape == self.phenotypes[0]):
                    a = 1
                elif (self.Shape == self.phenotypes[1]):
                    a = batch.number
                elif (self.Shape == self.phenotypes[2]):    
                    a = batch.type
                else:
                    a = 0
                    

                if (self.Color == self.phenotypes[0]):
                    b = 0
                elif(self.Color == self.phenotypes[1]):
                    b = batch.number
                elif(self.Color == self.phenotypes[2]): 
                    b = batch.type  
                else:
                    b = 0    '''

            a = batch.type
            b = batch.number

            tmarker = shapes[a]
            bcolor = self.colors[b]

            for i in range(len(x1)):
                points.append((x1[i], y1[i]))
            plot0 = create_scatter_plot((x1, y1),
                                        marker=tmarker,
                                        color=getColor(bcolor))

            if batch.isSelected:
                plot0.alpha = 1
                plot0.alpha = 1
            else:
                plot0.fill_alpha = 0.2
                plot0.edge_alpha = 0.2

            plot0.bgcolor = "white"
            plot0.border_visible = True

            if index == 0:
                value_mapper = plot0.value_mapper
                index_mapper = plot0.index_mapper
                add_default_grids(plot0)
                add_default_axes(plot0,
                                 vtitle='PCA Indices',
                                 htitle='PCA Scores')
                plot0.index_range.tight_bounds = False
                plot0.index_range.refresh()
                plot0.value_range.tight_bounds = False
                plot0.value_range.refresh()
                plot0.tools.append(PanTool(plot0))
                zoom = ZoomTool(plot0,
                                tool_mode="box",
                                always_on=False,
                                maintain_aspect_ratio=False)
                plot0.overlays.append(zoom)
                dragzoom = DragZoom(plot0,
                                    drag_button="right",
                                    maintain_aspect_ratio=False)
                plot0.tools.append(dragzoom)

            else:
                plot0.value_mapper = value_mapper
                value_mapper.range.add(plot0.value)
                plot0.index_mapper = index_mapper
                index_mapper.range.add(plot0.index)
            if batch.isSelected:
                Container.add(plot0)
            index = index + 1

        self.RightPlot = Container