Exemplo n.º 1
0
    def _signals_plot_default(self):
        print('_signals_plot_default')
        """Create the Plot instance."""

        plot = Plot()

        plot.add(self.signals_renderer)

        x_axis = PlotAxis(component=plot,
                          mapper=self.signals_renderer.index_mapper,
                          orientation='bottom')
        # y_axis = PlotAxis(component=plot,
        #                     mapper=self.signals_renderer.value_mapper,
        #                     orientation='left')
        plot.overlays.extend([x_axis])

        plot.origin_axis_visible = False
        plot.padding_top = 0
        plot.padding_left = 0
        plot.padding_right = 0
        plot.padding_bottom = 50
        plot.border_visible = False
        plot.bgcolor = "white"
        plot.use_downsampling = True
        return plot
Exemplo n.º 2
0
 def _create_corr_plot(self):
     plot = Plot(self.plotdata, padding=0)
     plot.padding_left = 25
     plot.padding_bottom = 25
     plot.tools.append(PanTool(plot))
     plot.overlays.append(ZoomTool(plot))
     self.corr_plot = plot
 def _create_corr_plot(self):
     plot = Plot(self.plotdata, padding=0)
     plot.padding_left = 25
     plot.padding_bottom = 25
     plot.tools.append(PanTool(plot))
     plot.overlays.append(ZoomTool(plot))
     self.corr_plot = plot
Exemplo n.º 4
0
    def _plot_default(self):
        plot = Plot(self.data)
        plot.plot( ('t', 'y0'), color=colors[0] )
        plot.padding=20
        plot.padding_left = 40

        plot.tools.append(PanTool(plot))#, constrain=True, constrain_direction="y"))
        #TODO: zoomtool works on both axes, should only affect y
        plot.tools.append(ZoomTool(plot, tool_mode="range", constrain=True, constrain_direction="y"))
        return plot
    def _plot1_2d_container_default(self):
        if self.cost_data is None or len(self.cost_data) == 0:
            return

        plot = Plot(self.cost_plot_data)
        plot.title = "Cost function"
        plot.padding_left = 80
        container = HPlotContainer()
        container.add(plot)
        self.rebuild_renderer(container)
        return container
Exemplo n.º 6
0
 def _plot_default(self):
     data = self.data < self.limit
     pd = self.pd = ArrayPlotData(imagedata=data,orig=self.data)
     plot1 = Plot(pd, default_origin='top left')
     plot2 = Plot(pd, default_origin='top left')
     img_plot1 = plot1.img_plot("imagedata",colormap=gray,padding=0)[0]
     img_plot2 = plot2.img_plot("orig",colormap=gray,padding=0)[0]
     container = HPlotContainer(plot1,plot2)
     container.spacing=0
     plot1.padding_right=0
     plot2.padding_left=0
     plot2.y_axis.orientation= 'right'
     return container
Exemplo n.º 7
0
    def _plot_default(self):
        container = Plot(self.model.plot_data, )
        container.renderer_map['bar'] = SelectableBarPlot
        container.padding_left = 100
        container.padding_bottom = 150
        # container.plot(('x', 'y'), type='bar')

        self.zoom_tool = ZoomTool(container, )
        container.underlays.append(self.zoom_tool)
        container.tools.append(self.zoom_tool)
        self.pan_tool = PanTool(container, )
        container.tools.append(self.pan_tool)

        return container
Exemplo n.º 8
0
    def _time_plot_default(self):
        plot = Plot(self.data)
        line_plot = plot.plot(('t', 'y'))[0]

        line_plot.active_tool = RangeSelection(line_plot, left_button_selects=True)
        line_plot.overlays.append(RangeSelectionOverlay(component=line_plot))
        self.selection = line_plot.active_tool

        plot.padding = 20
        plot.padding_left = 50

        self.selection.on_trait_change(self.handle_selection_change, 'selection')

        return plot
Exemplo n.º 9
0
    def _plot_default(self):
        plot = Plot(self.data)
        plot.plot(('t', 'y0'), color=colors[0])
        plot.padding = 20
        plot.padding_left = 40

        plot.tools.append(
            PanTool(plot))  #, constrain=True, constrain_direction="y"))
        #TODO: zoomtool works on both axes, should only affect y
        plot.tools.append(
            ZoomTool(plot,
                     tool_mode="range",
                     constrain=True,
                     constrain_direction="y"))
        return plot
Exemplo n.º 10
0
    def _time_plot_default(self):
        plot = Plot(self.data)
        line_plot = plot.plot(('t', 'y'))[0]

        line_plot.active_tool = RangeSelection(line_plot,
                                               left_button_selects=True)
        line_plot.overlays.append(RangeSelectionOverlay(component=line_plot))
        self.selection = line_plot.active_tool

        plot.padding = 20
        plot.padding_left = 50

        self.selection.on_trait_change(self.handle_selection_change,
                                       'selection')

        return plot
Exemplo n.º 11
0
    def __init__(self):
        # Create the data and the PlotData object
        x = linspace(-14, 14, 100)
        y = sin(x) * x**3
        plotdata = ArrayPlotData(x=x, y=y)
        # Create the scatter plot
        scatter = Plot(plotdata)
        scatter.plot(("x", "y"), type="scatter", color="blue")
        # Create the line plot
        line = Plot(plotdata)
        line.plot(("x", "y"), type="line", color="blue")
        # Create a horizontal container and put the two plots inside it
        container = HPlotContainer(scatter, line)
        container.spacing = 0
        scatter.padding_right = 0
        line.padding_left = 0
        line.y_axis.orientation = "right"

        self.plot = container
Exemplo n.º 12
0
    def _plot_default(self):
        # Create the data and the PlotData object
        x = linspace(-14, 14, 100)
        y = sin(x) * x**3
        plotdata = ArrayPlotData(x = x, y = y)
        # Create the scatter plot
        scatter = Plot(plotdata)
        scatter.plot(("x", "y"), type="scatter", color="blue")
        # Create the line plot
        line = Plot(plotdata)
        line.plot(("x", "y"), type="line", color="blue")
        # Create a horizontal container and put the two plots inside it
        container = HPlotContainer(scatter, line)
        container.spacing = 0
        scatter.padding_right = 0
        line.padding_left = 0
        line.y_axis.orientation = "right"

        return container
Exemplo n.º 13
0
    def _plot_default(self):
        container = Plot(
            self.model.plot_data,
            )
        container.renderer_map['bar'] = SelectableBarPlot
        container.padding_left = 100
        container.padding_bottom = 150
        # container.plot(('x', 'y'), type='bar')

        self.zoom_tool = ZoomTool(
            container,
            )
        container.underlays.append(self.zoom_tool)
        container.tools.append(self.zoom_tool)
        self.pan_tool = PanTool(
            container,
            )
        container.tools.append(self.pan_tool)

        return container
Exemplo n.º 14
0
    def _plot_default(self):
        x = linspace(-14, 14, 100)
        y = sin(x) * x**3
        plotdata = ArrayPlotData(x=x, y=y)

        scatter = Plot(plotdata)
        scatter.plot(("x", "y"), type="scatter", color="blue")

        line = Plot(plotdata)
        line.plot(("x", "y"), type="line", color="blue")

        container = HPlotContainer(scatter, line)
        container.spacing = 0

        scatter.padding_right = 0

        line.padding_left = 0
        line.y_axis_orientation = "right"

        return container
Exemplo n.º 15
0
    def _plot_default(self):
        plot = Plot(self.plot_data)
        self._update_plot_data()
        plot.plot(("counts", "approx"), color="red")
        plot.plot(("counts", "upper"), color="gray")
        plot.plot(("counts", "lower"), color="gray")
        plot.x_axis.title = "Counts (millions of points)"
        plot.y_axis.title = "Approximation"

        # Add dashed horizontal line at pi.
        pi_line = CoordinateLineOverlay(
            component=plot,
            value_data=[np.pi],
            color="green",
            line_style="dash",
        )
        plot.underlays.append(pi_line)

        # Allow extra room for the y-axis label.
        plot.padding_left = 100

        return plot
Exemplo n.º 16
0
    def __init__(self):
        super(ContainerExample, self).__init__()

        x = linspace(-14, 14, 100)
        y = sin(x) * x ** 3
        plotdata = ArrayPlotData(x=x, y=y)

        scatter = Plot(plotdata)
        scatter.plot(("x", "y"), type="scatter", color="blue")

        line = Plot(plotdata)
        line.plot(("x", "y"), type="line", color="blue")

        container = HPlotContainer(scatter, line)

        #Making the plots touch in the middle
        container.spacing = 0
        scatter.padding_right = 0
        line.padding_left = 0
        line.y_axis.orientation = "right"

        self.plot = container
Exemplo n.º 17
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                                          
Exemplo n.º 18
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)
Exemplo n.º 19
0
def _create_plot_component():
    army_lat = np.column_stack([army['start_lat'],
                                army['end_lat']]).reshape(-1)
    army_lon = np.column_stack([army['start_lon'],
                                army['end_lon']]).reshape(-1)

    plot_data = ArrayPlotData(
        army_lon=army_lon,
        army_lat=army_lat,
        army_size=army['size'],
        army_color=army['direction'] * army["group"],
        towns_lat=towns['lat'],
        towns_lon=towns['lon'],
        towns=towns['town'],
        temp_lon=temperatures['lon'],
        temp=temperatures['temp'],
        temp_date=temperatures['date'],
    )

    map_plot = Plot(plot_data)
    map_plot.x_grid = None
    map_plot.y_grid = None
    map_plot.x_axis.orientation = 'top'
    map_plot.x_axis.title = 'Longitude'
    map_plot.y_axis.title = 'Latitude'
    map_plot.title = "Minard's Map of Napoleon's Russian Campaign"
    map_plot._title.overlay_position = "inside top"
    map_plot._title.hjustify = "left"
    map_plot._title.vjustify = "bottom"
    map_plot.plot(
        ("army_lon", "army_lat", "army_color", "army_size"),
        type="cmap_segment",
        name="my_plot",
        color_mapper=viridis,
        border_visible=True,
        bgcolor="white",
        size_min=1.0,
        size_max=128.0,
    )
    map_plot.plot(
        ("towns_lon", "towns_lat"),
        type="scatter",
    )
    map_plot.plot(
        ("towns_lon", "towns_lat", "towns"),
        type="text",
        text_margin=4,
        h_position='right',
        text_offset=(4, 0),
    )
    map_plot.plot_1d(
        ('temp_lon'),
        type='line_scatter_1d',
        alpha=0.5,
        line_style='dot',
    )
    map_plot.index_range.high_setting = 38
    map_plot.index_range.low_setting = 23
    map_plot.value_range.high_setting = 56.0
    map_plot.value_range.low_setting = 53.5
    map_plot.tools.extend([
        PanTool(map_plot),
        ZoomTool(map_plot),
    ])

    temp_plot = Plot(plot_data, height=100)
    temp_plot.index_range = map_plot.index_range
    temp_plot.x_grid = None
    temp_plot.x_axis = None
    temp_plot.y_axis.orientation = 'right'
    temp_plot.y_axis.title = u'Temp (°Re)'
    temp_plot.plot(
        ('temp_lon', 'temp'),
        type='line',
    )
    temp_plot.plot_1d(
        ('temp_lon'),
        type='line_scatter_1d',
        alpha=0.5,
        line_style='dot',
    )
    temp_plot.plot_1d(
        ('temp_lon', 'temp_date'),
        type='textplot_1d',
        alpha=0.5,
        line_style='dot',
        alignment='bottom',
    )
    temp_plot.value_range.high_setting = 5
    temp_plot.value_range.low_setting = -35

    container = VPlotContainer(temp_plot, map_plot)
    container.spacing = 0
    map_plot.padding_bottom = 0
    map_plot.padding_left = 70
    map_plot.padding_right = 70
    map_plot.padding_top = 50
    temp_plot.padding_top = 0
    temp_plot.padding_bottom = 15
    temp_plot.padding_right = 70
    temp_plot.padding_left = 70
    temp_plot.height = 100
    temp_plot.resizable = 'h'

    return container
Exemplo n.º 20
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)
Exemplo n.º 21
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
Exemplo n.º 22
0
    def update_plots(self, waveforms, results):
        mic_psd = db(psd(waveforms, self.model.fs, 'hanning')).mean(axis=0)
        results['ref_mic_psd'] = mic_psd[1]
        results['exp_mic_psd'] = mic_psd[0]
        results['freq_psd'] = psd_freq(waveforms, self.model.fs)

        result = MicToneCalibrationResult(**results)
        frequency = results['frequency']
        ds = ArrayPlotData(freq_psd=results['freq_psd'],
                           exp_mic_psd=results['exp_mic_psd'],
                           ref_mic_psd=results['ref_mic_psd'],
                           time=results['time'],
                           exp_mic_waveform=results['exp_mic_waveform'],
                           ref_mic_waveform=results['ref_mic_waveform'])

        # Set up the waveform plot
        container = HPlotContainer(bgcolor='white', padding=10)
        plot = Plot(ds)
        plot.plot(('time', 'ref_mic_waveform'), color='black')
        plot.index_range.low_setting = self.model.trim
        plot.index_range.high_setting = 5.0/frequency+self.model.trim
        container.add(plot)
        plot = Plot(ds)
        plot.plot(('time', 'exp_mic_waveform'), color='red')
        plot.index_range.low_setting = self.model.trim
        plot.index_range.high_setting = 5.0/frequency+self.model.trim
        container.add(plot)
        result.waveform_plots = container

        # Set up the spectrum plot
        plot = Plot(ds)
        plot.plot(('freq_psd', 'ref_mic_psd'), color='black')
        plot.plot(('freq_psd', 'exp_mic_psd'), color='red')
        plot.index_scale = 'log'
        plot.title = 'Microphone response'
        plot.padding = 50
        plot.index_range.low_setting = 100
        plot.tools.append(PanTool(plot))
        zoom = ZoomTool(component=plot, tool_mode='box', always_on=False)
        plot.overlays.append(zoom)
        result.spectrum_plots = plot

        # Plot the fundamental (i.e. the tone) and first even/odd harmonics
        harmonic_container = HPlotContainer(resizable='hv', bgcolor='white',
                                            fill_padding=True, padding=10)
        for i in range(3):
            f_harmonic = results['exp_harmonics'][i]['frequency']
            plot = Plot(ds)
            plot.plot(('freq_psd', 'ref_mic_psd'), color='black')
            plot.plot(('freq_psd', 'exp_mic_psd'), color='red')
            plot.index_range.low_setting = f_harmonic-500
            plot.index_range.high_setting = f_harmonic+500
            plot.origin_axis_visible = True
            plot.padding_left = 10
            plot.padding_right = 10
            plot.border_visible = True
            plot.title = 'F{}'.format(i+1)
            harmonic_container.add(plot)
        result.harmonic_plots = harmonic_container

        self.model.tone_data.append(result)

        # Update the master overview
        self.model.measured_freq.append(results['frequency'])
        self.model.measured_spl.append(results['output_spl'])
        self.model.exp_mic_sens.append(results['exp_mic_sens'])
        for mic in ('ref', 'exp'):
            for h in range(3):
                v = results['{}_harmonics'.format(mic)][h]['mic_rms']
                name = 'measured_{}_f{}'.format(mic, h+1)
                getattr(self.model, name).append(v)
            v = results['{}_thd'.format(mic)]
            getattr(self.model, 'measured_{}_thd'.format(mic)).append(v)

        ds = ArrayPlotData(
            frequency=self.model.measured_freq,
            spl=self.model.measured_spl,
            measured_exp_thd=self.model.measured_exp_thd,
            measured_ref_thd=self.model.measured_ref_thd,
            exp_mic_sens=self.model.exp_mic_sens,
        )

        container = VPlotContainer(padding=10, bgcolor='white',
                                   fill_padding=True, resizable='hv')
        plot = Plot(ds)
        plot.plot(('frequency', 'spl'), color='black')
        plot.plot(('frequency', 'spl'), color='black', type='scatter')
        plot.index_scale = 'log'
        plot.title = 'Speaker output (dB SPL)'
        container.add(plot)

        plot = Plot(ds)
        plot.plot(('frequency', 'measured_ref_thd'), color='black')
        plot.plot(('frequency', 'measured_ref_thd'), color='black', type='scatter')
        plot.plot(('frequency', 'measured_exp_thd'), color='red')
        plot.plot(('frequency', 'measured_exp_thd'), color='red', type='scatter')
        plot.index_scale = 'log'
        plot.title = 'Total harmonic distortion (frac)'
        container.add(plot)

        plot = Plot(ds)
        plot.plot(('frequency', 'exp_mic_sens'), color='red')
        plot.plot(('frequency', 'exp_mic_sens'), color='red', type='scatter')
        plot.index_scale = 'log'
        plot.title = 'Experiment mic. sensitivity V (dB re Pa)'
        container.add(plot)

        self.model.spl_plots = container