Exemple #1
0
    def production_envelope_3d(self,
                               dataframe,
                               grid=None,
                               width=None,
                               height=None,
                               title=None,
                               points=None,
                               points_colors=None,
                               palette=None,
                               x_axis_label=None,
                               y_axis_label=None,
                               z_axis_label=None):

        variables = dataframe["strain"].unique()
        palette = self.get_option('palette') if palette is None else palette
        width = self.get_option('width') if width is None else width

        width, height = self.golden_ratio(width, height)
        data = []
        palette = self._palette(palette, len(variables))
        for variable, color in zip_repeat(variables, palette):
            _dataframe = dataframe[dataframe["strain"] == variable]
            surface = self._make_production_envelope_3d(_dataframe,
                                                        variable,
                                                        color=color)
            data.append(surface)

        if points is not None:
            x, y, z = zip(*points)
            scatter = go.Scatter3d(
                x=x,
                y=y,
                z=z,
                mode="markers",
                name="Data Points",
                marker=dict(
                    color="green" if points_colors is None else points_colors))
            data.append(scatter)

        layout = go.Layout(title=title,
                           scene=go.Scene(xaxis=dict(title=x_axis_label),
                                          yaxis=dict(title=y_axis_label),
                                          zaxis=dict(title=z_axis_label)),
                           width=width,
                           height=height)

        if grid is not None:
            plot = self.Figure(data=data, layout=layout)
            grid.append(plot)
            return grid
        else:
            plot = go.Figure(data=data, layout=layout)
        return plot
Exemple #2
0
    def production_envelope_3d(self, dataframe, grid=None, width=None, height=None, title=None,
                               points=None, points_colors=None, palette=None, x_axis_label=None,
                               y_axis_label=None, z_axis_label=None):

        variables = dataframe["strain"].unique()
        palette = self.get_option('palette') if palette is None else palette
        width = self.get_option('width') if width is None else width

        width, height = self.golden_ratio(width, height)
        data = []
        palette = self._palette(palette, len(variables))
        for variable, color in zip_repeat(variables, palette):
            _dataframe = dataframe[dataframe["strain"] == variable]
            surface = self._make_production_envelope_3d(_dataframe, variable, color=color)
            data.append(surface)

        if points is not None:
            x, y, z = zip(*points)
            scatter = go.Scatter3d(x=x, y=y, z=z, mode="markers", name="Data Points",
                                   marker=dict(color="green" if points_colors is None else points_colors))
            data.append(scatter)

        layout = go.Layout(
            title=title,
            scene=go.Scene(
                xaxis=dict(title=x_axis_label),
                yaxis=dict(title=y_axis_label),
                zaxis=dict(title=z_axis_label)),
            width=width,
            height=height
        )

        if grid is not None:
            plot = self.Figure(data=data, layout=layout)
            grid.append(plot)
            return grid
        else:
            plot = go.Figure(data=data, layout=layout)
        return plot