Esempio n. 1
0
    def __init__(self, plot_settings, title="Unnamed", x_label=None, y_label=None):
        self._title = title
        self._plot_settings = plot_settings
        if self._plot_settings is None:
            raise ValueError('PlotConfig needs a non-None plot settings.')
        self._line_color_cycle_colors = ["#000000"]
        self._line_color_cycle = itertools.cycle(self._line_color_cycle_colors) #Black
        # Blueish, Greenlike, Beigeoid, Pinkness, Orangy-Brown
        self.setLineColorCycle(["#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"])
        # alternative color cycle:
        # ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33",
        #  "#a65628", "#f781bf" ,"#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"]

        self._legend_items = []
        self._legend_labels = []

        self._x_label = x_label
        self._y_label = y_label

        self._limits = PlotLimits()

        self._default_style = PlotStyle(name="Default", color=None, alpha=0.8)

        self._refcase_style = PlotStyle(name="Refcase", alpha=0.8, line_style="--", marker="", width=2.0,
                                        enabled=self._plot_settings["SHOW_REFCASE"])

        self._history_style = PlotStyle(name="History", alpha=0.8, marker=".", width=2.0,
                                        enabled=self._plot_settings["SHOW_HISTORY"])

        self._observs_style = PlotStyle(name="Observations", line_style="-", alpha=0.8,
                                        marker=".", width=1.0, color="#000000")

        self._histogram_style = PlotStyle(name="Histogram", width=2.0)
        self._distribution_style = PlotStyle(name="Distribution", line_style="", marker="o", alpha=0.5, size=10.0)
        self._distribution_line_style = PlotStyle(name="Distribution Lines", line_style="-", alpha=0.25, width=1.0)
        self._distribution_line_style.setEnabled(False)
        self._current_color = None

        self._legend_enabled = True
        self._grid_enabled = True


        self._statistics_style = {
            "mean": PlotStyle("Mean", line_style=""),
            "p50": PlotStyle("P50", line_style=""),
            "min-max": PlotStyle("Min/Max", line_style=""),
            "p10-p90": PlotStyle("P10-P90", line_style=""),
            "p33-p67": PlotStyle("P33-P67", line_style=""),
            "std": PlotStyle("Std dev", line_style="")
        }

        self._std_dev_factor = 1 # sigma 1 is default std dev
Esempio n. 2
0
    def test_plot_limits_construction(self):
        plot_limits = PlotLimits()
        self.assertEqual(plot_limits.value_minimum, None)
        self.assertEqual(plot_limits.value_maximum, None)
        self.assertEqual(plot_limits.value_limits, (None, None))

        self.assertEqual(plot_limits.index_minimum, None)
        self.assertEqual(plot_limits.index_maximum, None)
        self.assertEqual(plot_limits.index_limits, (None, None))

        self.assertEqual(plot_limits.count_minimum, None)
        self.assertEqual(plot_limits.count_maximum, None)
        self.assertEqual(plot_limits.count_limits, (None, None))

        self.assertEqual(plot_limits.density_minimum, None)
        self.assertEqual(plot_limits.density_maximum, None)
        self.assertEqual(plot_limits.density_limits, (None, None))

        self.assertEqual(plot_limits.depth_minimum, None)
        self.assertEqual(plot_limits.depth_maximum, None)
        self.assertEqual(plot_limits.depth_limits, (None, None))

        self.assertEqual(plot_limits.date_minimum, None)
        self.assertEqual(plot_limits.date_maximum, None)
        self.assertEqual(plot_limits.date_limits, (None, None))
Esempio n. 3
0
    def test_copy_plot_limits(self):
        plot_limits = PlotLimits()
        plot_limits.value_limits = 1, 2
        plot_limits.index_limits = 3, 4
        plot_limits.count_limits = 5, 6
        plot_limits.depth_limits = 7, 8
        plot_limits.density_limits = 9, 10
        plot_limits.date_limits = datetime.date(1999, 1, 1), datetime.date(1999, 12, 31)

        copy_of_plot_limits = PlotLimits()

        copy_of_plot_limits.copyLimitsFrom(plot_limits)

        self.assertEqual(copy_of_plot_limits, plot_limits)

        self.assertEqual(copy_of_plot_limits.value_limits, (1, 2))
        self.assertEqual(copy_of_plot_limits.index_limits, (3, 4))
        self.assertEqual(copy_of_plot_limits.count_limits, (5, 6))
        self.assertEqual(copy_of_plot_limits.depth_limits, (7, 8))
        self.assertEqual(copy_of_plot_limits.density_limits, (9, 10))
        self.assertEqual(copy_of_plot_limits.date_limits, (datetime.date(1999, 1, 1), datetime.date(1999, 12, 31)))
Esempio n. 4
0
    def __init__(self, plot_settings, title="Unnamed", x_label=None, y_label=None):
        self._title = title
        self._plot_settings = plot_settings
        if self._plot_settings is None:
            raise ValueError('PlotConfig needs a non-None plot settings.')
        self._line_color_cycle_colors = ["#000000"]
        self._line_color_cycle = itertools.cycle(self._line_color_cycle_colors) #Black
        # Blueish, Greenlike, Beigeoid, Pinkness, Orangy-Brown
        self.setLineColorCycle(["#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"])
        # alternative color cycle:
        # ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33",
        #  "#a65628", "#f781bf" ,"#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"]

        self._legend_items = []
        self._legend_labels = []

        self._x_label = x_label
        self._y_label = y_label

        self._limits = PlotLimits()

        self._default_style = PlotStyle(name="Default", color=None, alpha=0.8)

        self._refcase_style = PlotStyle(name="Refcase", alpha=0.8, line_style="--", marker="", width=2.0,
                                        enabled=self._plot_settings["SHOW_REFCASE"])

        self._history_style = PlotStyle(name="History", alpha=0.8, marker=".", width=2.0,
                                        enabled=self._plot_settings["SHOW_HISTORY"])

        self._observs_style = PlotStyle(name="Observations", line_style="-", alpha=0.8,
                                        marker=".", width=1.0, color="#000000")

        self._histogram_style = PlotStyle(name="Histogram", width=2.0)
        self._distribution_style = PlotStyle(name="Distribution", line_style="", marker="o", alpha=0.5, size=10.0)
        self._distribution_line_style = PlotStyle(name="Distribution Lines", line_style="-", alpha=0.25, width=1.0)
        self._distribution_line_style.setEnabled(False)
        self._current_color = None

        self._legend_enabled = True
        self._grid_enabled = True


        self._statistics_style = {
            "mean": PlotStyle("Mean", line_style=""),
            "p50": PlotStyle("P50", line_style=""),
            "min-max": PlotStyle("Min/Max", line_style=""),
            "p10-p90": PlotStyle("P10-P90", line_style=""),
            "p33-p67": PlotStyle("P33-P67", line_style=""),
            "std": PlotStyle("Std dev", line_style="")
        }

        self._std_dev_factor = 1 # sigma 1 is default std dev
Esempio n. 5
0
    def __init__(self, title="Unnamed", x_label=None, y_label=None):
        super(PlotConfig, self).__init__()
        self._title = title

        self._line_color_cycle_colors = ["#000000"]
        self._line_color_cycle = itertools.cycle(self._line_color_cycle_colors) #Black
        # Blueish, Greenlike, Beigeoid, Pinkness, Orangy-Brown
        self.setLineColorCycle(["#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"])
#        self.setLineColorCycle(["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf" ,"#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"])

        self._legend_items = []
        self._legend_labels = []

        self._x_label = x_label
        self._y_label = y_label

        self._limits = PlotLimits()

        self._default_style = PlotStyle(name="Default", color=None, alpha=0.8)
        self._refcase_style = PlotStyle(name="Refcase", alpha=0.8, marker="x", width=2.0)
        self._history_style = PlotStyle(name="History", alpha=0.8, marker="D", width=2.0)

        # Insanely ugly implementation of user preferences.
        if os.getenv("ERT_SHOW_HISTORY_VECTORS"):
            self._history_style.setEnabled(True)
        else:
            self._history_style.setEnabled(False)

        self._observation_style = PlotStyle(name="Observations")
        self._histogram_style = PlotStyle(name="Histogram", width=2.0)
        self._distribution_style = PlotStyle(name="Distribution", line_style="", marker="o", alpha=0.5, size=10.0)
        self._distribution_line_style = PlotStyle(name="Distribution Lines", line_style="-", alpha=0.25, width=1.0)
        self._distribution_line_style.setEnabled(False)
        self._current_color = None

        self._legend_enabled = True
        self._grid_enabled = True


        self._statistics_style = {
            "mean": PlotStyle("Mean", line_style=""),
            "p50": PlotStyle("P50", line_style=""),
            "min-max": PlotStyle("Min/Max", line_style=""),
            "p10-p90": PlotStyle("P10-P90", line_style=""),
            "p33-p67": PlotStyle("P33-P67", line_style=""),
            "std": PlotStyle("Std dev", line_style="")
        }

        self._std_dev_factor = 1 # sigma 1 is default std dev
Esempio n. 6
0
    def test_plot_config(self):
        ps = PlotSettings()
        plot_config = PlotConfig(ps, "Golden Sample", x_label="x", y_label="y")

        limits = PlotLimits()
        limits.count_limits = 1, 2
        limits.depth_limits = 3, 4
        limits.density_limits = 5, 6
        limits.date_limits = datetime.date(2005, 2,
                                           5), datetime.date(2006, 2, 6)
        limits.index_limits = 7, 8
        limits.value_limits = 9.0, 10.0

        plot_config.limits = limits
        self.assertEqual(plot_config.limits, limits)

        plot_config.setDistributionLineEnabled(True)
        plot_config.setLegendEnabled(False)
        plot_config.setGridEnabled(False)
        plot_config.setRefcaseEnabled(False)
        plot_config.setObservationsEnabled(False)

        style = PlotStyle("test_style",
                          line_style=".",
                          marker="g",
                          width=2.5,
                          size=7.5)

        plot_config.setDefaultStyle(style)
        plot_config.setRefcaseStyle(style)
        plot_config.setStatisticsStyle("mean", style)
        plot_config.setStatisticsStyle("min-max", style)
        plot_config.setStatisticsStyle("p50", style)
        plot_config.setStatisticsStyle("p10-p90", style)
        plot_config.setStatisticsStyle("p33-p67", style)
        plot_config.setStatisticsStyle("std", style)

        copy_of_plot_config = PlotConfig(ps, "Copy of Golden Sample")
        copy_of_plot_config.copyConfigFrom(plot_config)

        self.assertEqual(plot_config.isLegendEnabled(),
                         copy_of_plot_config.isLegendEnabled())
        self.assertEqual(plot_config.isGridEnabled(),
                         copy_of_plot_config.isGridEnabled())
        self.assertEqual(plot_config.isObservationsEnabled(),
                         copy_of_plot_config.isObservationsEnabled())
        self.assertEqual(plot_config.isDistributionLineEnabled(),
                         copy_of_plot_config.isDistributionLineEnabled())

        self.assertEqual(plot_config.refcaseStyle(),
                         copy_of_plot_config.refcaseStyle())
        self.assertEqual(plot_config.observationsStyle(),
                         copy_of_plot_config.observationsStyle())

        self.assertEqual(plot_config.histogramStyle(),
                         copy_of_plot_config.histogramStyle())
        self.assertEqual(plot_config.defaultStyle(),
                         copy_of_plot_config.defaultStyle())
        self.assertEqual(plot_config.currentColor(),
                         copy_of_plot_config.currentColor())

        self.assertEqual(plot_config.getStatisticsStyle("mean"),
                         copy_of_plot_config.getStatisticsStyle("mean"))
        self.assertEqual(plot_config.getStatisticsStyle("min-max"),
                         copy_of_plot_config.getStatisticsStyle("min-max"))
        self.assertEqual(plot_config.getStatisticsStyle("p50"),
                         copy_of_plot_config.getStatisticsStyle("p50"))
        self.assertEqual(plot_config.getStatisticsStyle("p10-p90"),
                         copy_of_plot_config.getStatisticsStyle("p10-p90"))
        self.assertEqual(plot_config.getStatisticsStyle("p33-p67"),
                         copy_of_plot_config.getStatisticsStyle("p33-p67"))
        self.assertEqual(plot_config.getStatisticsStyle("std"),
                         copy_of_plot_config.getStatisticsStyle("std"))

        self.assertEqual(plot_config.title(), copy_of_plot_config.title())

        self.assertEqual(plot_config.limits, copy_of_plot_config.limits)

        plot_config.currentColor()  # cycle state will not be copied
        plot_config.nextColor()

        copy_of_plot_config = PlotConfig(ps, "Another Copy of Golden Sample")
        copy_of_plot_config.copyConfigFrom(plot_config)

        self.assertEqual(plot_config.refcaseStyle(),
                         copy_of_plot_config.refcaseStyle())
        self.assertEqual(plot_config.observationsStyle(),
                         copy_of_plot_config.observationsStyle())

        self.assertNotEqual(plot_config.histogramStyle(),
                            copy_of_plot_config.histogramStyle())
        self.assertNotEqual(plot_config.defaultStyle(),
                            copy_of_plot_config.defaultStyle())
        self.assertNotEqual(plot_config.currentColor(),
                            copy_of_plot_config.currentColor())

        self.assertNotEqual(plot_config.getStatisticsStyle("mean"),
                            copy_of_plot_config.getStatisticsStyle("mean"))
        self.assertNotEqual(plot_config.getStatisticsStyle("min-max"),
                            copy_of_plot_config.getStatisticsStyle("min-max"))
        self.assertNotEqual(plot_config.getStatisticsStyle("p50"),
                            copy_of_plot_config.getStatisticsStyle("p50"))
        self.assertNotEqual(plot_config.getStatisticsStyle("p10-p90"),
                            copy_of_plot_config.getStatisticsStyle("p10-p90"))
        self.assertNotEqual(plot_config.getStatisticsStyle("p33-p67"),
                            copy_of_plot_config.getStatisticsStyle("p33-p67"))
        self.assertNotEqual(plot_config.getStatisticsStyle("std"),
                            copy_of_plot_config.getStatisticsStyle("std"))
Esempio n. 7
0
class PlotConfig(object):

    # The plot_settings input argument is an internalisation of the (quite few) plot
    # policy settings which can be set in the configuration file.

    def __init__(self, plot_settings=None, title="Unnamed", x_label=None, y_label=None):
        self._title = title
        self._plot_settings = plot_settings
        if self._plot_settings is None:
            self._plot_settings = {"SHOW_REFCASE": True, "SHOW_HISTORY": True}

        self._line_color_cycle_colors = ["#000000"]
        self._line_color_cycle = itertools.cycle(self._line_color_cycle_colors)  # Black
        # Blueish, Greenlike, Beigeoid, Pinkness, Orangy-Brown
        self.setLineColorCycle(["#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"])
        # alternative color cycle:
        # ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33",
        #  "#a65628", "#f781bf" ,"#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"]

        self._legend_items = []
        self._legend_labels = []

        self._x_label = x_label
        self._y_label = y_label

        self._limits = PlotLimits()

        self._default_style = PlotStyle(
            name="Default", color=None, marker="", alpha=0.8
        )

        self._refcase_style = PlotStyle(
            name="Refcase",
            alpha=0.8,
            line_style="--",
            marker="",
            width=2.0,
            enabled=self._plot_settings["SHOW_REFCASE"],
        )

        self._history_style = PlotStyle(
            name="History",
            alpha=0.8,
            marker=".",
            width=2.0,
            enabled=self._plot_settings["SHOW_HISTORY"],
        )

        self._observs_style = PlotStyle(
            name="Observations",
            line_style="-",
            alpha=0.8,
            marker=".",
            width=1.0,
            color="#000000",
        )

        self._histogram_style = PlotStyle(name="Histogram", width=2.0)
        self._distribution_style = PlotStyle(
            name="Distribution", line_style="", marker="o", alpha=0.5, size=10.0
        )
        self._distribution_line_style = PlotStyle(
            name="Distribution Lines", line_style="-", alpha=0.25, width=1.0
        )
        self._distribution_line_style.setEnabled(False)
        self._current_color = None

        self._legend_enabled = True
        self._grid_enabled = True

        self._statistics_style = {
            "mean": PlotStyle("Mean", line_style=""),
            "p50": PlotStyle("P50", line_style=""),
            "min-max": PlotStyle("Min/Max", line_style=""),
            "p10-p90": PlotStyle("P10-P90", line_style=""),
            "p33-p67": PlotStyle("P33-P67", line_style=""),
            "std": PlotStyle("Std dev", line_style=""),
        }

        self._std_dev_factor = 1  # sigma 1 is default std dev

    def currentColor(self):
        if self._current_color is None:
            self.nextColor()

        return self._current_color

    def nextColor(self):
        self._current_color = next(self._line_color_cycle)
        return self._current_color

    def setLineColorCycle(self, color_list):
        self._line_color_cycle_colors = color_list
        self._line_color_cycle = itertools.cycle(color_list)

    def lineColorCycle(self):
        return list(self._line_color_cycle_colors)

    def addLegendItem(self, label, item):
        self._legend_items.append(item)
        self._legend_labels.append(label)

    def title(self):
        """:rtype: str"""
        return self._title if self._title is not None else "Unnamed"

    def setTitle(self, title):
        self._title = title

    def isUnnamed(self):
        return self._title is None

    def defaultStyle(self):
        style = PlotStyle("Default Style")
        style.copyStyleFrom(self._default_style)
        style.color = self.currentColor()
        return style

    def observationsColor(self):
        return self._observs_style.color

    def observationsStyle(self):
        """@rtype: PlotStyle"""
        style = PlotStyle("Observations Style")
        style.copyStyleFrom(self._observs_style)
        return style

    def refcaseStyle(self):
        """@rtype: PlotStyle"""
        style = PlotStyle("Refcase Style")
        style.copyStyleFrom(self._refcase_style)
        return style

    def historyStyle(self):
        """@rtype: PlotStyle"""
        style = PlotStyle("History Style")
        style.copyStyleFrom(self._history_style)
        return style

    def histogramStyle(self):
        """@rtype: PlotStyle"""
        style = PlotStyle("Histogram Style")
        style.copyStyleFrom(self._histogram_style)
        style.color = self.currentColor()
        return style

    def distributionStyle(self):
        """@rtype: PlotStyle"""
        style = PlotStyle("Distribution Style")
        style.copyStyleFrom(self._distribution_style)
        style.color = self.currentColor()
        return style

    def distributionLineStyle(self):
        """@rtype: ert_gui.plottery.PlotStyle"""
        style = PlotStyle("Distribution Line Style")
        style.copyStyleFrom(self._distribution_line_style)
        return style

    def xLabel(self):
        return self._x_label

    def yLabel(self):
        return self._y_label

    def legendItems(self):
        return self._legend_items

    def legendLabels(self):
        return self._legend_labels

    def setXLabel(self, label):
        self._x_label = label

    def setYLabel(self, label):
        self._y_label = label

    def setObservationsEnabled(self, enabled):
        self._observs_style.setEnabled(enabled)

    def isObservationsEnabled(self):
        return self._observs_style.isEnabled()

    def setRefcaseEnabled(self, enabled):
        self._refcase_style.setEnabled(enabled)

    def isRefcaseEnabled(self):
        return self._refcase_style.isEnabled()

    def setHistoryEnabled(self, enabled):
        self._history_style.setEnabled(enabled)

    def isHistoryEnabled(self):
        return self._history_style.isEnabled()

    def isLegendEnabled(self):
        return self._legend_enabled

    def isDistributionLineEnabled(self):
        return self._distribution_line_style.isEnabled()

    def setDistributionLineEnabled(self, enabled):
        self._distribution_line_style.setEnabled(enabled)

    def setStandardDeviationFactor(self, value):
        self._std_dev_factor = value

    def getStandardDeviationFactor(self):
        return self._std_dev_factor

    def setLegendEnabled(self, enabled):
        self._legend_enabled = enabled

    def isGridEnabled(self):
        return self._grid_enabled

    def setGridEnabled(self, enabled):
        self._grid_enabled = enabled

    def setStatisticsStyle(self, statistic, style):
        """
        @type statistic: str
        @type style: PlotStyle
        """

        statistics_style = self._statistics_style[statistic]
        statistics_style.line_style = style.line_style
        statistics_style.marker = style.marker
        statistics_style.width = style.width
        statistics_style.size = style.size

    def getStatisticsStyle(self, statistic):
        style = self._statistics_style[statistic]
        copy_style = PlotStyle(style.name)
        copy_style.copyStyleFrom(style)
        copy_style.color = self.currentColor()
        return copy_style

    def setRefcaseStyle(self, style):
        """@type style: PlotStyle"""
        self._refcase_style.line_style = style.line_style
        self._refcase_style.marker = style.marker
        self._refcase_style.width = style.width
        self._refcase_style.size = style.size

    def setHistoryStyle(self, style):
        """@type style: PlotStyle"""
        self._history_style.line_style = style.line_style
        self._history_style.marker = style.marker
        self._history_style.width = style.width
        self._history_style.size = style.size

    def setObservationsColor(self, color):
        self._observs_style.color = color

    def setObservationsStyle(self, style):
        """@type style: PlotStyle"""
        self._observs_style.line_style = style.line_style
        self._observs_style.marker = style.marker
        self._observs_style.width = style.width
        self._observs_style.size = style.size

    def setDefaultStyle(self, style):
        """@type style: PlotStyle"""
        self._default_style.line_style = style.line_style
        self._default_style.marker = style.marker
        self._default_style.width = style.width
        self._default_style.size = style.size

    @property
    def limits(self):
        """@rtype: PlotLimits"""
        limits = PlotLimits()
        limits.copyLimitsFrom(self._limits)
        return limits

    @limits.setter
    def limits(self, value):
        """@type value: PlotLimits"""
        self._limits.copyLimitsFrom(value)

    def copyConfigFrom(self, other):
        """
        :type other: PlotConfig
        """
        self._default_style.copyStyleFrom(other._default_style, copy_enabled_state=True)
        self._refcase_style.copyStyleFrom(other._refcase_style, copy_enabled_state=True)
        self._history_style.copyStyleFrom(other._history_style, copy_enabled_state=True)
        self._histogram_style.copyStyleFrom(
            other._histogram_style, copy_enabled_state=True
        )
        self._observs_style.copyStyleFrom(other._observs_style, copy_enabled_state=True)
        self._distribution_style.copyStyleFrom(
            other._distribution_style, copy_enabled_state=True
        )
        self._distribution_line_style.copyStyleFrom(
            other._distribution_line_style, copy_enabled_state=True
        )

        self._statistics_style["mean"].copyStyleFrom(
            other._statistics_style["mean"], copy_enabled_state=True
        )
        self._statistics_style["p50"].copyStyleFrom(
            other._statistics_style["p50"], copy_enabled_state=True
        )
        self._statistics_style["min-max"].copyStyleFrom(
            other._statistics_style["min-max"], copy_enabled_state=True
        )
        self._statistics_style["p10-p90"].copyStyleFrom(
            other._statistics_style["p10-p90"], copy_enabled_state=True
        )
        self._statistics_style["p33-p67"].copyStyleFrom(
            other._statistics_style["p33-p67"], copy_enabled_state=True
        )
        self._statistics_style["std"].copyStyleFrom(
            other._statistics_style["std"], copy_enabled_state=True
        )

        self._std_dev_factor = other._std_dev_factor
        self._legend_enabled = other._legend_enabled
        self._grid_enabled = other._grid_enabled

        self.setLineColorCycle(other._line_color_cycle_colors)

        self._legend_items = other._legend_items[:]
        self._legend_labels = other._legend_labels[:]

        self._x_label = other._x_label
        self._y_label = other._y_label

        self._limits.copyLimitsFrom(other._limits)

        if other._title is not None:
            self._title = other._title

    @classmethod
    def createCopy(cls, other):
        copy = PlotConfig(other._plot_settings)
        copy.copyConfigFrom(other)
        return copy
Esempio n. 8
0
 def limits(self):
     """@rtype: PlotLimits"""
     limits = PlotLimits()
     limits.copyLimitsFrom(self._limits)
     return limits
Esempio n. 9
0
    def test_plot_config(self):
        ps = PlotSettings( )
        plot_config = PlotConfig(ps , "Golden Sample", x_label="x", y_label="y")

        limits = PlotLimits()
        limits.count_limits = 1, 2
        limits.depth_limits = 3, 4
        limits.density_limits = 5, 6
        limits.date_limits = datetime.date(2005, 2, 5), datetime.date(2006, 2, 6)
        limits.index_limits = 7, 8
        limits.value_limits = 9.0, 10.0

        plot_config.limits = limits
        self.assertEqual(plot_config.limits, limits)

        plot_config.setDistributionLineEnabled(True)
        plot_config.setLegendEnabled(False)
        plot_config.setGridEnabled(False)
        plot_config.setRefcaseEnabled(False)
        plot_config.setObservationsEnabled(False)

        style = PlotStyle("test_style", line_style=".", marker="g", width=2.5, size=7.5)

        plot_config.setDefaultStyle(style)
        plot_config.setRefcaseStyle(style)
        plot_config.setStatisticsStyle("mean", style)
        plot_config.setStatisticsStyle("min-max", style)
        plot_config.setStatisticsStyle("p50", style)
        plot_config.setStatisticsStyle("p10-p90", style)
        plot_config.setStatisticsStyle("p33-p67", style)
        plot_config.setStatisticsStyle("std", style)

        copy_of_plot_config = PlotConfig(ps , "Copy of Golden Sample")
        copy_of_plot_config.copyConfigFrom(plot_config)

        self.assertEqual(plot_config.isLegendEnabled(), copy_of_plot_config.isLegendEnabled())
        self.assertEqual(plot_config.isGridEnabled(), copy_of_plot_config.isGridEnabled())
        self.assertEqual(plot_config.isObservationsEnabled(), copy_of_plot_config.isObservationsEnabled())
        self.assertEqual(plot_config.isDistributionLineEnabled(), copy_of_plot_config.isDistributionLineEnabled())

        self.assertEqual(plot_config.refcaseStyle(), copy_of_plot_config.refcaseStyle())
        self.assertEqual(plot_config.observationsStyle(), copy_of_plot_config.observationsStyle())

        self.assertEqual(plot_config.histogramStyle(), copy_of_plot_config.histogramStyle())
        self.assertEqual(plot_config.defaultStyle(), copy_of_plot_config.defaultStyle())
        self.assertEqual(plot_config.currentColor(), copy_of_plot_config.currentColor())

        self.assertEqual(plot_config.getStatisticsStyle("mean"), copy_of_plot_config.getStatisticsStyle("mean"))
        self.assertEqual(plot_config.getStatisticsStyle("min-max"), copy_of_plot_config.getStatisticsStyle("min-max"))
        self.assertEqual(plot_config.getStatisticsStyle("p50"), copy_of_plot_config.getStatisticsStyle("p50"))
        self.assertEqual(plot_config.getStatisticsStyle("p10-p90"), copy_of_plot_config.getStatisticsStyle("p10-p90"))
        self.assertEqual(plot_config.getStatisticsStyle("p33-p67"), copy_of_plot_config.getStatisticsStyle("p33-p67"))
        self.assertEqual(plot_config.getStatisticsStyle("std"), copy_of_plot_config.getStatisticsStyle("std"))

        self.assertEqual(plot_config.title(), copy_of_plot_config.title())

        self.assertEqual(plot_config.limits, copy_of_plot_config.limits)


        plot_config.currentColor()  # cycle state will not be copied
        plot_config.nextColor()

        copy_of_plot_config = PlotConfig(ps, "Another Copy of Golden Sample")
        copy_of_plot_config.copyConfigFrom(plot_config)

        self.assertEqual(plot_config.refcaseStyle(), copy_of_plot_config.refcaseStyle())
        self.assertEqual(plot_config.observationsStyle(), copy_of_plot_config.observationsStyle())

        self.assertNotEqual(plot_config.histogramStyle(), copy_of_plot_config.histogramStyle())
        self.assertNotEqual(plot_config.defaultStyle(), copy_of_plot_config.defaultStyle())
        self.assertNotEqual(plot_config.currentColor(), copy_of_plot_config.currentColor())

        self.assertNotEqual(plot_config.getStatisticsStyle("mean"), copy_of_plot_config.getStatisticsStyle("mean"))
        self.assertNotEqual(plot_config.getStatisticsStyle("min-max"), copy_of_plot_config.getStatisticsStyle("min-max"))
        self.assertNotEqual(plot_config.getStatisticsStyle("p50"), copy_of_plot_config.getStatisticsStyle("p50"))
        self.assertNotEqual(plot_config.getStatisticsStyle("p10-p90"), copy_of_plot_config.getStatisticsStyle("p10-p90"))
        self.assertNotEqual(plot_config.getStatisticsStyle("p33-p67"), copy_of_plot_config.getStatisticsStyle("p33-p67"))
        self.assertNotEqual(plot_config.getStatisticsStyle("std"), copy_of_plot_config.getStatisticsStyle("std"))
Esempio n. 10
0
    def test_plot_limits(self):
        plot_limits = PlotLimits()
        limit_names = ["value", "index", "count", "density", "depth", "date"]

        non_numbers = [
            "string",
            datetime.date(2001, 1, 1), "3.0", "1e-5", "-5.5", "-.5"
        ]

        positive_floats = [1.0, 1.5, 3.1415, 1e10, 5.2e-7]
        negative_floats = [-1.0, -1.5, -3.1415, -1e10, -5.2e-7]
        positive_ints = [1, 5, 1000]
        negative_ints = [-1, -5, -1000]

        non_dates = ["string", "3.4", "2001-01-01", datetime.time()]
        dates = [datetime.date(2001, 1, 1), datetime.datetime(2010, 3, 3)]

        setter_should_fail_values = {
            "value": non_numbers + dates,
            "index": non_numbers + positive_floats + negative_floats + dates,
            "depth":
            non_numbers + negative_floats + negative_ints + negative_ints,
            "count":
            non_numbers + negative_ints + negative_floats + positive_floats,
            "density": non_numbers + negative_floats + negative_ints,
            "date": non_dates
        }

        setter_should_succeed_values = {
            "value":
            positive_floats + negative_floats + positive_ints + negative_ints,
            "index": positive_ints,
            "depth": positive_floats + positive_ints,
            "count": positive_ints,
            "density": positive_floats + positive_ints,
            "date": dates
        }

        for attribute_name in limit_names:
            self.assertIsNone(
                getattr(plot_limits, "%s_minimum" % attribute_name))
            self.assertIsNone(
                getattr(plot_limits, "%s_maximum" % attribute_name))
            self.assertTupleEqual(
                getattr(plot_limits, "%s_limits" % attribute_name),
                (None, None))

            with self.assertNotRaises():
                setattr(plot_limits, "%s_minimum" % attribute_name, None)
                setattr(plot_limits, "%s_maximum" % attribute_name, None)
                setattr(plot_limits, "%s_limits" % attribute_name,
                        (None, None))

            with self.assertRaises(TypeError):
                setattr(plot_limits, "%s_limits" % attribute_name, None)

            for value in setter_should_fail_values[attribute_name]:
                with self.assertRaises((TypeError, ValueError)):
                    setattr(plot_limits, "%s_minimum" % attribute_name, value)

                with self.assertRaises((TypeError, ValueError)):
                    setattr(plot_limits, "%s_maximum" % attribute_name, value)

                self.assertTupleEqual(
                    getattr(plot_limits, "%s_limits" % attribute_name),
                    (None, None))

            for value in setter_should_succeed_values[attribute_name]:
                with self.assertNotRaises():
                    setattr(plot_limits, "%s_minimum" % attribute_name, value)
                    setattr(plot_limits, "%s_maximum" % attribute_name, value)

                minimum = getattr(plot_limits, "%s_minimum" % attribute_name)
                maximum = getattr(plot_limits, "%s_maximum" % attribute_name)

                self.assertEqual(minimum, value)
                self.assertEqual(maximum, value)

                self.assertTupleEqual(
                    getattr(plot_limits, "%s_limits" % attribute_name),
                    (minimum, maximum))
Esempio n. 11
0
    def test_copy_plot_limits(self):
        plot_limits = PlotLimits()
        plot_limits.value_limits = 1, 2
        plot_limits.index_limits = 3, 4
        plot_limits.count_limits = 5, 6
        plot_limits.depth_limits = 7, 8
        plot_limits.density_limits = 9, 10
        plot_limits.date_limits = datetime.date(1999, 1, 1), datetime.date(
            1999, 12, 31)

        copy_of_plot_limits = PlotLimits()

        copy_of_plot_limits.copyLimitsFrom(plot_limits)

        self.assertEqual(copy_of_plot_limits, plot_limits)

        self.assertEqual(copy_of_plot_limits.value_limits, (1, 2))
        self.assertEqual(copy_of_plot_limits.index_limits, (3, 4))
        self.assertEqual(copy_of_plot_limits.count_limits, (5, 6))
        self.assertEqual(copy_of_plot_limits.depth_limits, (7, 8))
        self.assertEqual(copy_of_plot_limits.density_limits, (9, 10))
        self.assertEqual(
            copy_of_plot_limits.date_limits,
            (datetime.date(1999, 1, 1), datetime.date(1999, 12, 31)))
Esempio n. 12
0
    def __init__(self, title="Unnamed", x_label=None, y_label=None):
        super(PlotConfig, self).__init__()
        self._title = title

        self._line_color_cycle_colors = ["#000000"]
        self._line_color_cycle = itertools.cycle(
            self._line_color_cycle_colors)  #Black
        # Blueish, Greenlike, Beigeoid, Pinkness, Orangy-Brown
        self.setLineColorCycle(
            ["#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"])

        self._legend_items = []
        self._legend_labels = []

        self._x_label = x_label
        self._y_label = y_label

        self._limits = PlotLimits()

        self._default_style = PlotStyle(name="Default", color=None, alpha=0.8)
        self._refcase_style = PlotStyle(name="Refcase",
                                        alpha=0.8,
                                        marker="x",
                                        width=2.0)
        self._history_style = PlotStyle(name="History",
                                        alpha=0.8,
                                        marker="D",
                                        width=2.0)

        # Insanely ugly implementation of user preferences.
        if os.getenv("ERT_SHOW_HISTORY_VECTORS"):
            self._history_style.setEnabled(True)
        else:
            self._history_style.setEnabled(False)

        self._observation_style = PlotStyle(name="Observations")
        self._histogram_style = PlotStyle(name="Histogram", width=2.0)
        self._distribution_style = PlotStyle(name="Distribution",
                                             line_style="",
                                             marker="o",
                                             alpha=0.5,
                                             size=10.0)
        self._distribution_line_style = PlotStyle(name="Distribution Lines",
                                                  line_style="-",
                                                  alpha=0.25,
                                                  width=1.0)
        self._distribution_line_style.setEnabled(False)
        self._current_color = None

        self._legend_enabled = True
        self._grid_enabled = True

        self._statistics_style = {
            "mean": PlotStyle("Mean", line_style=""),
            "p50": PlotStyle("P50", line_style=""),
            "min-max": PlotStyle("Min/Max", line_style=""),
            "p10-p90": PlotStyle("P10-P90", line_style=""),
            "p33-p67": PlotStyle("P33-P67", line_style=""),
            "std": PlotStyle("Std dev", line_style="")
        }

        self._std_dev_factor = 1  # sigma 1 is default std dev
Esempio n. 13
0
class PlotConfig(object):
    def __init__(self, title="Unnamed", x_label=None, y_label=None):
        super(PlotConfig, self).__init__()
        self._title = title

        self._line_color_cycle_colors = ["#000000"]
        self._line_color_cycle = itertools.cycle(
            self._line_color_cycle_colors)  #Black
        # Blueish, Greenlike, Beigeoid, Pinkness, Orangy-Brown
        self.setLineColorCycle(
            ["#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"])

        self._legend_items = []
        self._legend_labels = []

        self._x_label = x_label
        self._y_label = y_label

        self._limits = PlotLimits()

        self._default_style = PlotStyle(name="Default", color=None, alpha=0.8)
        self._refcase_style = PlotStyle(name="Refcase",
                                        alpha=0.8,
                                        marker="x",
                                        width=2.0)
        self._history_style = PlotStyle(name="History",
                                        alpha=0.8,
                                        marker="D",
                                        width=2.0)

        # Insanely ugly implementation of user preferences.
        if os.getenv("ERT_SHOW_HISTORY_VECTORS"):
            self._history_style.setEnabled(True)
        else:
            self._history_style.setEnabled(False)

        self._observation_style = PlotStyle(name="Observations")
        self._histogram_style = PlotStyle(name="Histogram", width=2.0)
        self._distribution_style = PlotStyle(name="Distribution",
                                             line_style="",
                                             marker="o",
                                             alpha=0.5,
                                             size=10.0)
        self._distribution_line_style = PlotStyle(name="Distribution Lines",
                                                  line_style="-",
                                                  alpha=0.25,
                                                  width=1.0)
        self._distribution_line_style.setEnabled(False)
        self._current_color = None

        self._legend_enabled = True
        self._grid_enabled = True

        self._statistics_style = {
            "mean": PlotStyle("Mean", line_style=""),
            "p50": PlotStyle("P50", line_style=""),
            "min-max": PlotStyle("Min/Max", line_style=""),
            "p10-p90": PlotStyle("P10-P90", line_style=""),
            "p33-p67": PlotStyle("P33-P67", line_style=""),
            "std": PlotStyle("Std dev", line_style="")
        }

        self._std_dev_factor = 1  # sigma 1 is default std dev

    def currentColor(self):
        if self._current_color is None:
            self.nextColor()

        return self._current_color

    def nextColor(self):
        self._current_color = self._line_color_cycle.next()
        return self._current_color

    def setLineColorCycle(self, color_list):
        self._line_color_cycle_colors = color_list
        self._line_color_cycle = itertools.cycle(color_list)

    def lineColorCycle(self):
        return list(self._line_color_cycle_colors)

    def addLegendItem(self, label, item):
        self._legend_items.append(item)
        self._legend_labels.append(label)

    def title(self):
        """ :rtype: str """
        return self._title if self._title is not None else "Unnamed"

    def setTitle(self, title):
        self._title = title

    def isUnnamed(self):
        return self._title is None

    def defaultStyle(self):
        style = PlotStyle("Default Style")
        style.copyStyleFrom(self._default_style)
        style.color = self.currentColor()
        return style

    def observationsStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("Observations Style")
        style.copyStyleFrom(self._observation_style)
        return style

    def refcaseStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("Refcase Style")
        style.copyStyleFrom(self._refcase_style)
        return style

    def historyStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("History Style")
        style.copyStyleFrom(self._history_style)
        return style

    def histogramStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("Histogram Style")
        style.copyStyleFrom(self._histogram_style)
        style.color = self.currentColor()
        return style

    def distributionStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("Distribution Style")
        style.copyStyleFrom(self._distribution_style)
        style.color = self.currentColor()
        return style

    def distributionLineStyle(self):
        """ @rtype: ert_gui.plottery.PlotStyle """
        style = PlotStyle("Distribution Line Style")
        style.copyStyleFrom(self._distribution_line_style)
        return style

    def xLabel(self):
        return self._x_label

    def yLabel(self):
        return self._y_label

    def legendItems(self):
        return self._legend_items

    def legendLabels(self):
        return self._legend_labels

    def setXLabel(self, label):
        self._x_label = label

    def setYLabel(self, label):
        self._y_label = label

    def setObservationsEnabled(self, enabled):
        self._observation_style.setEnabled(enabled)

    def isObservationsEnabled(self):
        return self._observation_style.isEnabled()

    def setRefcaseEnabled(self, enabled):
        self._refcase_style.setEnabled(enabled)

    def isRefcaseEnabled(self):
        return self._refcase_style.isEnabled()

    def setHistoryEnabled(self, enabled):
        self._history_style.setEnabled(enabled)

    def isHistoryEnabled(self):
        return self._history_style.isEnabled()

    def isLegendEnabled(self):
        return self._legend_enabled

    def isDistributionLineEnabled(self):
        return self._distribution_line_style.isEnabled()

    def setDistributionLineEnabled(self, enabled):
        self._distribution_line_style.setEnabled(enabled)

    def setStandardDeviationFactor(self, value):
        self._std_dev_factor = value

    def getStandardDeviationFactor(self):
        return self._std_dev_factor

    def setLegendEnabled(self, enabled):
        self._legend_enabled = enabled

    def isGridEnabled(self):
        return self._grid_enabled

    def setGridEnabled(self, enabled):
        self._grid_enabled = enabled

    def setStatisticsStyle(self, statistic, style):
        """
        @type statistic: str
        @type style: PlotStyle
        """

        statistics_style = self._statistics_style[statistic]
        statistics_style.line_style = style.line_style
        statistics_style.marker = style.marker
        statistics_style.width = style.width
        statistics_style.size = style.size

    def getStatisticsStyle(self, statistic):
        style = self._statistics_style[statistic]
        copy_style = PlotStyle(style.name)
        copy_style.copyStyleFrom(style)
        copy_style.color = self.currentColor()
        return copy_style

    def setRefcaseStyle(self, style):
        """ @type style: PlotStyle """
        self._refcase_style.line_style = style.line_style
        self._refcase_style.marker = style.marker
        self._refcase_style.width = style.width
        self._refcase_style.size = style.size

    def setHistoryStyle(self, style):
        """ @type style: PlotStyle """
        self._history_style.line_style = style.line_style
        self._history_style.marker = style.marker
        self._history_style.width = style.width
        self._history_style.size = style.size

    def setDefaultStyle(self, style):
        """ @type style: PlotStyle """
        self._default_style.line_style = style.line_style
        self._default_style.marker = style.marker
        self._default_style.width = style.width
        self._default_style.size = style.size

    @property
    def limits(self):
        """ @rtype: PlotLimits """
        limits = PlotLimits()
        limits.copyLimitsFrom(self._limits)
        return limits

    @limits.setter
    def limits(self, value):
        """ @type value: PlotLimits """
        self._limits.copyLimitsFrom(value)

    def copyConfigFrom(self, other):
        """
        :type other: PlotConfig
        """
        self._default_style.copyStyleFrom(other._default_style,
                                          copy_enabled_state=True)
        self._refcase_style.copyStyleFrom(other._refcase_style,
                                          copy_enabled_state=True)
        self._history_style.copyStyleFrom(other._history_style,
                                          copy_enabled_state=True)
        self._histogram_style.copyStyleFrom(other._histogram_style,
                                            copy_enabled_state=True)
        self._observation_style.copyStyleFrom(other._observation_style,
                                              copy_enabled_state=True)
        self._distribution_style.copyStyleFrom(other._distribution_style,
                                               copy_enabled_state=True)
        self._distribution_line_style.copyStyleFrom(
            other._distribution_line_style, copy_enabled_state=True)

        self._statistics_style["mean"].copyStyleFrom(
            other._statistics_style["mean"], copy_enabled_state=True)
        self._statistics_style["p50"].copyStyleFrom(
            other._statistics_style["p50"], copy_enabled_state=True)
        self._statistics_style["min-max"].copyStyleFrom(
            other._statistics_style["min-max"], copy_enabled_state=True)
        self._statistics_style["p10-p90"].copyStyleFrom(
            other._statistics_style["p10-p90"], copy_enabled_state=True)
        self._statistics_style["p33-p67"].copyStyleFrom(
            other._statistics_style["p33-p67"], copy_enabled_state=True)
        self._statistics_style["std"].copyStyleFrom(
            other._statistics_style["std"], copy_enabled_state=True)

        self._std_dev_factor = other._std_dev_factor
        self._legend_enabled = other._legend_enabled
        self._grid_enabled = other._grid_enabled

        self.setLineColorCycle(other._line_color_cycle_colors)

        self._legend_items = other._legend_items[:]
        self._legend_labels = other._legend_labels[:]

        self._x_label = other._x_label
        self._y_label = other._y_label

        self._limits.copyLimitsFrom(other._limits)

        if other._title is not None:
            self._title = other._title

    @classmethod
    def createCopy(cls, other):
        copy = PlotConfig(None)
        copy.copyConfigFrom(other)
        return copy
Esempio n. 14
0
class PlotConfig(object):

    def __init__(self, title="Unnamed", x_label=None, y_label=None):
        super(PlotConfig, self).__init__()
        self._title = title

        self._line_color_cycle_colors = ["#000000"]
        self._line_color_cycle = itertools.cycle(self._line_color_cycle_colors) #Black
        # Blueish, Greenlike, Beigeoid, Pinkness, Orangy-Brown
        self.setLineColorCycle(["#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"])
#        self.setLineColorCycle(["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf" ,"#386CB0", "#7FC97F", "#FDC086", "#F0027F", "#BF5B17"])

        self._legend_items = []
        self._legend_labels = []

        self._x_label = x_label
        self._y_label = y_label

        self._limits = PlotLimits()

        self._default_style = PlotStyle(name="Default", color=None, alpha=0.8)
        self._refcase_style = PlotStyle(name="Refcase", alpha=0.8, marker="x", width=2.0)
        self._history_style = PlotStyle(name="History", alpha=0.8, marker="D", width=2.0)

        # Insanely ugly implementation of user preferences.
        if os.getenv("ERT_SHOW_HISTORY_VECTORS"):
            self._history_style.setEnabled(True)
        else:
            self._history_style.setEnabled(False)

        self._observation_style = PlotStyle(name="Observations")
        self._histogram_style = PlotStyle(name="Histogram", width=2.0)
        self._distribution_style = PlotStyle(name="Distribution", line_style="", marker="o", alpha=0.5, size=10.0)
        self._distribution_line_style = PlotStyle(name="Distribution Lines", line_style="-", alpha=0.25, width=1.0)
        self._distribution_line_style.setEnabled(False)
        self._current_color = None

        self._legend_enabled = True
        self._grid_enabled = True


        self._statistics_style = {
            "mean": PlotStyle("Mean", line_style=""),
            "p50": PlotStyle("P50", line_style=""),
            "min-max": PlotStyle("Min/Max", line_style=""),
            "p10-p90": PlotStyle("P10-P90", line_style=""),
            "p33-p67": PlotStyle("P33-P67", line_style=""),
            "std": PlotStyle("Std dev", line_style="")
        }

        self._std_dev_factor = 1 # sigma 1 is default std dev

    def currentColor(self):
        if self._current_color is None:
            self.nextColor()

        return self._current_color

    def nextColor(self):
        self._current_color = self._line_color_cycle.next()
        return self._current_color

    def setLineColorCycle(self, color_list):
        self._line_color_cycle_colors = color_list
        self._line_color_cycle = itertools.cycle(color_list)

    def lineColorCycle(self):
        return list(self._line_color_cycle_colors)

    def addLegendItem(self, label, item):
        self._legend_items.append(item)
        self._legend_labels.append(label)

    def title(self):
        """ :rtype: str """
        return self._title if self._title is not None else "Unnamed"

    def setTitle(self, title):
        self._title = title

    def isUnnamed(self):
        return self._title is None

    def defaultStyle(self):
        style = PlotStyle("Default Style")
        style.copyStyleFrom(self._default_style)
        style.color = self.currentColor()
        return style

    def observationsStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("Observations Style")
        style.copyStyleFrom(self._observation_style)
        return style

    def refcaseStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("Refcase Style")
        style.copyStyleFrom(self._refcase_style)
        return style

    def historyStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("History Style")
        style.copyStyleFrom(self._history_style)
        return style

    def histogramStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("Histogram Style")
        style.copyStyleFrom(self._histogram_style)
        style.color = self.currentColor()
        return style

    def distributionStyle(self):
        """ @rtype: PlotStyle """
        style = PlotStyle("Distribution Style")
        style.copyStyleFrom(self._distribution_style)
        style.color = self.currentColor()
        return style

    def distributionLineStyle(self):
        """ @rtype: ert_gui.plottery.PlotStyle """
        style = PlotStyle("Distribution Line Style")
        style.copyStyleFrom(self._distribution_line_style)
        return style

    def xLabel(self):
        return self._x_label

    def yLabel(self):
        return self._y_label

    def legendItems(self):
        return self._legend_items

    def legendLabels(self):
        return self._legend_labels

    def setXLabel(self, label):
        self._x_label = label

    def setYLabel(self, label):
        self._y_label = label

    def setObservationsEnabled(self, enabled):
        self._observation_style.setEnabled(enabled)

    def isObservationsEnabled(self):
        return self._observation_style.isEnabled()

    def setRefcaseEnabled(self, enabled):
        self._refcase_style.setEnabled(enabled)

    def isRefcaseEnabled(self):
        return self._refcase_style.isEnabled()

    def setHistoryEnabled(self, enabled):
        self._history_style.setEnabled(enabled)

    def isHistoryEnabled(self):
        return self._history_style.isEnabled()

    def isLegendEnabled(self):
        return self._legend_enabled

    def isDistributionLineEnabled(self):
        return self._distribution_line_style.isEnabled()

    def setDistributionLineEnabled(self, enabled):
        self._distribution_line_style.setEnabled(enabled)

    def setStandardDeviationFactor(self, value):
        self._std_dev_factor = value

    def getStandardDeviationFactor(self):
        return self._std_dev_factor

    def setLegendEnabled(self, enabled):
        self._legend_enabled = enabled

    def isGridEnabled(self):
        return self._grid_enabled

    def setGridEnabled(self, enabled):
        self._grid_enabled = enabled

    def setStatisticsStyle(self, statistic, style):
        """
        @type statistic: str
        @type style: PlotStyle
        """

        statistics_style = self._statistics_style[statistic]
        statistics_style.line_style = style.line_style
        statistics_style.marker = style.marker
        statistics_style.width = style.width
        statistics_style.size = style.size

    def getStatisticsStyle(self, statistic):
        style = self._statistics_style[statistic]
        copy_style = PlotStyle(style.name)
        copy_style.copyStyleFrom(style)
        copy_style.color = self.currentColor()
        return copy_style

    def setRefcaseStyle(self, style):
        """ @type style: PlotStyle """
        self._refcase_style.line_style = style.line_style
        self._refcase_style.marker = style.marker
        self._refcase_style.width = style.width
        self._refcase_style.size = style.size

    def setHistoryStyle(self, style):
        """ @type style: PlotStyle """
        self._history_style.line_style = style.line_style
        self._history_style.marker = style.marker
        self._history_style.width = style.width
        self._history_style.size = style.size


    def setDefaultStyle(self, style):
        """ @type style: PlotStyle """
        self._default_style.line_style = style.line_style
        self._default_style.marker = style.marker
        self._default_style.width = style.width
        self._default_style.size = style.size


    @property
    def limits(self):
        """ @rtype: PlotLimits """
        limits = PlotLimits()
        limits.copyLimitsFrom(self._limits)
        return limits

    @limits.setter
    def limits(self, value):
        """ @type value: PlotLimits """
        self._limits.copyLimitsFrom(value)


    def copyConfigFrom(self, other):
        """
        :type other: PlotConfig
        """
        self._default_style.copyStyleFrom(other._default_style, copy_enabled_state=True)
        self._refcase_style.copyStyleFrom(other._refcase_style, copy_enabled_state=True)
        self._history_style.copyStyleFrom(other._history_style, copy_enabled_state=True)
        self._histogram_style.copyStyleFrom(other._histogram_style, copy_enabled_state=True)
        self._observation_style.copyStyleFrom(other._observation_style, copy_enabled_state=True)
        self._distribution_style.copyStyleFrom(other._distribution_style, copy_enabled_state=True)
        self._distribution_line_style.copyStyleFrom(other._distribution_line_style, copy_enabled_state=True)

        self._statistics_style["mean"].copyStyleFrom(other._statistics_style["mean"], copy_enabled_state=True)
        self._statistics_style["p50"].copyStyleFrom(other._statistics_style["p50"], copy_enabled_state=True)
        self._statistics_style["min-max"].copyStyleFrom(other._statistics_style["min-max"], copy_enabled_state=True)
        self._statistics_style["p10-p90"].copyStyleFrom(other._statistics_style["p10-p90"], copy_enabled_state=True)
        self._statistics_style["p33-p67"].copyStyleFrom(other._statistics_style["p33-p67"], copy_enabled_state=True)
        self._statistics_style["std"].copyStyleFrom(other._statistics_style["std"], copy_enabled_state=True)

        self._std_dev_factor = other._std_dev_factor
        self._legend_enabled = other._legend_enabled
        self._grid_enabled = other._grid_enabled

        self.setLineColorCycle(other._line_color_cycle_colors)

        self._legend_items = other._legend_items[:]
        self._legend_labels = other._legend_labels[:]

        self._x_label = other._x_label
        self._y_label = other._y_label

        self._limits.copyLimitsFrom(other._limits)

        if other._title is not None:
            self._title = other._title

    @classmethod
    def createCopy(cls, other):
        copy = PlotConfig(None)
        copy.copyConfigFrom(other)
        return copy
Esempio n. 15
0
 def limits(self):
     """ @rtype: PlotLimits """
     limits = PlotLimits()
     limits.copyLimitsFrom(self._limits)
     return limits