diff --git a/ertviz/controllers/multi_response_controller.py b/ertviz/controllers/multi_response_controller.py index 1f44fb44..a6dff5ec 100644 --- a/ertviz/controllers/multi_response_controller.py +++ b/ertviz/controllers/multi_response_controller.py @@ -52,6 +52,11 @@ def _get_observation_plots(observation_df, x_axis): stds = observation_df["std"] x_axis = observation_df["x_axis"] attributes = observation_df["attributes"] + active_mask = observation_df["active"] + + style = assets.ERTSTYLE["response-plot"]["observation"] + color = [style["color"] if active else "rgb(0, 0, 0)" for active in active_mask] + style["marker"]["color"] = color observation_data = PlotModel( x_axis=x_axis, @@ -63,9 +68,8 @@ def _get_observation_plots(observation_df, x_axis): array=stds.values, visible=True, ), - **assets.ERTSTYLE["response-plot"]["observation"], + **style, ) - return [observation_data] diff --git a/ertviz/models/observation.py b/ertviz/models/observation.py index 3bd7261b..030f2157 100644 --- a/ertviz/models/observation.py +++ b/ertviz/models/observation.py @@ -9,12 +9,14 @@ def __init__(self, observation_schema): self._std = [] self._values = [] self._attributes = "" + self._active = [] if "data" in observation_schema: data = observation_schema["data"] self._x_axis = data["x_axis"]["data"] self._std = data["std"]["data"] self._values = data["values"]["data"] + self._active = data["active"]["data"] if "attributes" in observation_schema: for k, v in observation_schema["attributes"].items(): @@ -27,5 +29,6 @@ def data_df(self): "std": self._std, "x_axis": indexes_to_axis(self._x_axis), "attributes": self._attributes, + "active": self._active, } ) diff --git a/ertviz/models/plot_model.py b/ertviz/models/plot_model.py index 07989f05..98689e50 100644 --- a/ertviz/models/plot_model.py +++ b/ertviz/models/plot_model.py @@ -184,8 +184,8 @@ def repr(self): repr_dict = dict( x=self._x_axis, y=self._y_axis, - name=self.display_name, text=self._text, + name=self.display_name, mode=self._mode, error_y=self._error_y, ) diff --git a/tests/data/snake_oil_data.py b/tests/data/snake_oil_data.py index 8114b790..e7a98d1a 100644 --- a/tests/data/snake_oil_data.py +++ b/tests/data/snake_oil_data.py @@ -249,6 +249,20 @@ def content(self): "x_axis": {"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}, "std": {"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}, "values": {"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}, + "active": { + "data": [ + True, + True, + False, + False, + True, + True, + True, + True, + True, + False, + ] + }, }, "name": "FOPR", } @@ -310,6 +324,20 @@ def content(self): "x_axis": {"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}, "std": {"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}, "values": {"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}, + "active": { + "data": [ + True, + True, + False, + False, + True, + True, + True, + True, + True, + False, + ] + }, }, "name": "WOPR:OP1", } @@ -334,6 +362,20 @@ def content(self): "x_axis": {"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}, "std": {"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}, "values": {"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}, + "active": { + "data": [ + True, + True, + False, + False, + True, + True, + True, + True, + True, + False, + ] + }, }, "name": "FOPR", } diff --git a/tests/plots/test_controller.py b/tests/plots/test_controller.py index b4d5a813..f13f10ae 100644 --- a/tests/plots/test_controller.py +++ b/tests/plots/test_controller.py @@ -28,6 +28,7 @@ def test_observation_plot_representation(): "std": [0.1, 1.1, 4.1, 9.1, 16.1], "x_axis": [0, 2, 4, 6, 8], "attributes": "Key1 Value1
Key2 Value2
", + "active": [True, False, True, False, False], } ) x_axis = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] @@ -42,6 +43,16 @@ def test_observation_plot_representation(): np.testing.assert_equal(plots[0].repr.y, observation_df["values"].values) np.testing.assert_equal(plots[0].repr.error_y.array, observation_df["std"].values) np.testing.assert_equal(plots[0].repr.text, observation_df["attributes"].values) + np.testing.assert_equal( + plots[0].repr.marker.color, + ( + "rgb(176, 28, 52)", + "rgb(0, 0, 0)", + "rgb(176, 28, 52)", + "rgb(0, 0, 0)", + "rgb(0, 0, 0)", + ), + ) def test_realizations_plot_representation():