def plot()

in src/lookoutequipment/plot.py [0:0]


    def plot(self, fig_width=18, colors=DEFAULT_COLORS, labels_bottom=False, no_legend=False):
        """
        Renders the plot as configured with the previous function
        
        Parameters:
            fig_width (integer):
                The width of the figure to generate (defaults to 18)
                
        Returns:
            tuple: tuple containing:
                * A ``matplotlib.pyplot.figure`` where the plots are drawn
                * A ``list of matplotlib.pyplot.Axis`` with each plot drawn here
        """
        # Prepare the figure structure:
        self._set_plot_shared_params()
        fig = plt.figure(figsize=(fig_width, self.fig_height))
        gs = gridspec.GridSpec(nrows=self.nb_plots, 
                               ncols=1, 
                               height_ratios=self.height_ratios, 
                               hspace=0.5)
        ax = []
        for i in range(self.nb_plots):
            ax.append(fig.add_subplot(gs[i]))
            
        # First, we plot the time series signals:
        ax_id = 0
        for signal_df in self._signals_data:
            tag_name = signal_df.columns[0]
            
            # If we don't want to highlight training and evaluation period
            # we only plot the signal as is:
            if self._tag_split is None:
                ax[ax_id].plot(signal_df, alpha=0.8, label=tag_name)

            # Otherwise, we plot the training part in grey and the evaluation
            # part in color:
            else:
                self._plot_split_signal(signal_df, tag_name, ax[ax_id])
                
            # We can display a daily rolling average:
            if self._rolling_average:
                self._plot_rolling_average(signal_df, ax[ax_id])

        # Next, we plot the labels ranges, except if they should be at the bottom:
        if (self._labels_df is not None) and (labels_bottom == False):
            ax_id += 1
            self._plot_ranges(
                self._labels_df, 
                self._labels_title,
                colors['labels'],
                ax[ax_id]
            )

        # Next, we plot the detected event ranges:
        if len(self._predictions_df) > 0:
            for prediction_title, predictions_df in zip(self._predictions_title, self._predictions_df):
                ax_id += 1
                self._plot_ranges(
                    predictions_df, 
                    prediction_title, 
                    colors['predictions'],
                    ax[ax_id]
                )
                
        # Next, we plot the labels ranges, if they should be at the bottom:
        if (self._labels_df is not None) and (labels_bottom == True):
            ax_id += 1
            self._plot_ranges(
                self._labels_df, 
                self._labels_title,
                colors['labels'],
                ax[ax_id]
            )
                           
        # Legends:
        if not no_legend:
            ax[0].legend(**self._legend_format)
                               
        return fig, ax