Skip to content

Commit 91d37b4

Browse files
committed
Move dimensionality-specific styles to PlotConfig
PlotConfigFactory existed only to build a PlotConfig and then override a few statistics line styles based on the dimensionality of the selected key.
1 parent ae2f9f1 commit 91d37b4

5 files changed

Lines changed: 66 additions & 40 deletions

File tree

src/ert/gui/plotting/plot_window.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@
4545
HISTOGRAM,
4646
MISFITS,
4747
SHARED_PLOT_MAP,
48+
STATISTICS,
4849
STD_DEV,
4950
)
5051
from ert.gui.utils import is_everest_application
5152
from ert.services import ServerBootFail
5253
from ert.utils import log_duration
5354

5455
from .plot_api import EnsembleObject, PlotApi, PlotApiKeyDefinition
55-
from .utils import PlotConfigFactory, PlotContext
56+
from .utils import PlotConfig, PlotContext
5657
from .utils.observation_locations import transform_observation_locations
5758
from .utils.plot_color_palettes import TABLEAU_10_COLOR_CYCLE
5859
from .utils.plot_types import ObservationPlotLocations
@@ -536,7 +537,11 @@ def fetch_data(
536537
except BaseException as e:
537538
handle_exception(e)
538539

539-
plot_config = PlotConfigFactory.create_plot_config_for_key(key_def)
540+
plot_config = PlotConfig(title=key_def.key)
541+
if selected_tab == STATISTICS:
542+
plot_config.set_statistics_styles_for_dimensionality(
543+
key_def.dimensionality
544+
)
540545
plot_config.set_title(self._titles.get(key_def.key, key_def.key))
541546
plot_config.set_x_label(self._x_labels.get(key_def.key))
542547
plot_config.set_y_label(self._y_labels.get(key_def.key))

src/ert/gui/plotting/utils/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
register_matplotlib_converters()
99

1010
from .plot_config import PlotConfig
11-
from .plot_config_factory import PlotConfigFactory
1211
from .plot_context import PlotContext
1312
from .plot_style import PlotStyle
1413
from .plot_tools import ConditionalAxisFormatter, PlotTools
@@ -26,7 +25,6 @@
2625
"LineTooltipManager",
2726
"ObservationPlotLocations",
2827
"PlotConfig",
29-
"PlotConfigFactory",
3028
"PlotContext",
3129
"PlotStyle",
3230
"PlotTools",

src/ert/gui/plotting/utils/plot_config.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ def __init__(
7676
self.flip_response_axis = False
7777
self.flip_observation_axis = False
7878

79+
def set_statistics_styles_for_dimensionality(self, dimensionality: int) -> None:
80+
mean_style = self._statistics_style["mean"]
81+
p10p90_style = self._statistics_style["p10-p90"]
82+
std_style = self._statistics_style["std"]
83+
84+
mean_style.line_style = ""
85+
mean_style.marker = ""
86+
p10p90_style.line_style = ""
87+
p10p90_style.marker = ""
88+
std_style.line_style = ""
89+
std_style.marker = ""
90+
91+
if dimensionality == 2:
92+
mean_style.line_style = "-"
93+
p10p90_style.line_style = "--"
94+
elif dimensionality == 1:
95+
mean_style.line_style = "-"
96+
mean_style.marker = "o"
97+
std_style.line_style = "--"
98+
std_style.marker = "D"
99+
79100
def get_number_of_colors(self) -> int:
80101
return len(self._line_color_cycle_colors)
81102

src/ert/gui/plotting/utils/plot_config_factory.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/ert/unit_tests/gui/plottery/test_plot_style.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,41 @@ def test_plot_config():
203203
assert plot_config.get_statistics_style(
204204
"std"
205205
) != copy_of_plot_config.get_statistics_style("std")
206+
207+
208+
def test_that_two_dimensional_keys_draw_mean_and_p10_p90_as_lines():
209+
plot_config = PlotConfig()
210+
plot_config.set_statistics_styles_for_dimensionality(1)
211+
212+
plot_config.set_statistics_styles_for_dimensionality(2)
213+
214+
mean_style = plot_config.get_statistics_style("mean")
215+
assert mean_style.line_style == "-"
216+
assert not mean_style.marker
217+
218+
p10p90_style = plot_config.get_statistics_style("p10-p90")
219+
assert p10p90_style.line_style == "--"
220+
assert not p10p90_style.marker
221+
222+
std_style = plot_config.get_statistics_style("std")
223+
assert not std_style.line_style
224+
assert not std_style.marker
225+
226+
227+
def test_that_one_dimensional_keys_draw_mean_and_std_with_markers():
228+
plot_config = PlotConfig()
229+
plot_config.set_statistics_styles_for_dimensionality(2)
230+
231+
plot_config.set_statistics_styles_for_dimensionality(1)
232+
233+
mean_style = plot_config.get_statistics_style("mean")
234+
assert mean_style.line_style == "-"
235+
assert mean_style.marker == "o"
236+
237+
std_style = plot_config.get_statistics_style("std")
238+
assert std_style.line_style == "--"
239+
assert std_style.marker == "D"
240+
241+
p10p90_style = plot_config.get_statistics_style("p10-p90")
242+
assert not p10p90_style.line_style
243+
assert not p10p90_style.marker

0 commit comments

Comments
 (0)