Beispiel #1
0
    def __init__(self, times, data):
        self.data_ = data

        # Create the data and the PlotData object
        self.plotdata = ArrayPlotData(time=times, 
                                      xdata=self.data_[:,0],
                                      ydata=self.data_[:,1],
                                      zdata=self.data_[:,2])

        # Create a Plot and associate it with the PlotData
        plot = Plot(self.plotdata)
        
        # Create line plots
        plot.plot(("time", "xdata"), type="line", color="blue", name="x")
        plot.plot(("time", "ydata"), type="line", color="green", name="y")
        plot.plot(("time", "zdata"), type="line", color="red", name="z")
        
        for p in self.colors.keys():
            plot.hideplot(p)

        plot.tools.append(PanTool(plot))
        plot.tools.append(ZoomTool(plot, tool_mode='box', always_on=True, drag_button="right"))
        #plot.tools.append(DragZoom(plot, drag_button="right"))

        self.plot = plot
Beispiel #2
0
 def _plot_default(self):
     global data_plot
     data_dict = {}
     this_count = 1
     plot_list = []
     for icol, col_data in data_plot.plot_data.items():
         this_x, this_xerr, this_y, this_yerr, this_fit, this_key_select = data_plot.PlotElement(
             col_data, IgnorePlot=True)
         if this_x is None or this_x is False: continue
         plot_list.append(col_data['label'])
         data_dict['x_' + str(this_count)] = this_x
         data_dict['y_' + str(this_count)] = this_y
         data_dict['yup_' +
                   str(this_count)] = np.array(this_y) + np.array(this_yerr)
         data_dict['ydown_' +
                   str(this_count)] = np.array(this_y) - np.array(this_yerr)
         this_count += 1
     self.plotdata = ArrayPlotData(**data_dict)
     plot = Plot(self.plotdata)
     self.line_dict = {}
     for iplot, plot_name in enumerate(plot_list):
         this_col = simple_col[iplot % len(simple_col)]
         self.line_dict['y_' + str(iplot + 1)] = plot.plot(
             ('x_' + str(iplot + 1), 'y_' + str(iplot + 1)),
             type="line",
             color=this_col,
             name=plot_name)[0]
         self.line_dict['yup_' + str(iplot + 1)] = plot.plot(
             ('x_' + str(iplot + 1), 'yup_' + str(iplot + 1)),
             type="line",
             color=this_col,
             alpha=0.5,
             name=plot_name + '_up')[0]
         self.line_dict['ydown_' + str(iplot + 1)] = plot.plot(
             ('x_' + str(iplot + 1), 'ydown_' + str(iplot + 1)),
             type="line",
             color=this_col,
             alpha=0.5,
             name=plot_name + '_down')[0]
         if not data_plot.plot_data[plot_name]['plot_this']:
             plot.hideplot(plot_name)
             plot.hideplot(plot_name + '_up')
             plot.hideplot(plot_name + '_down')
     plot.title = 'Test Plot'
     plot.legend.visible = True
     self.key_list = list(plot_list)
     self.index_key = 0
     self.this_key = self.key_list[0]
     self.dim_list = data_plot.plot_data[
         self.this_key]['y_data'].index.names
     return plot