diff --git a/setup.py b/setup.py index 6b3027764..41e9d1863 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ "pillow~=6.1", "xtgeo~=2.1", "webviz-config>=0.0.48", - "webviz-subsurface-components>=0.0.20", + "webviz-subsurface-components>=0.0.22", ], tests_require=TESTS_REQUIRE, extras_require={"tests": TESTS_REQUIRE}, diff --git a/webviz_subsurface/plugins/_parameter_distribution.py b/webviz_subsurface/plugins/_parameter_distribution.py index 5f5673c03..f0ac060a0 100644 --- a/webviz_subsurface/plugins/_parameter_distribution.py +++ b/webviz_subsurface/plugins/_parameter_distribution.py @@ -2,13 +2,12 @@ from pathlib import Path import pandas as pd -import plotly.express as px import dash from dash.exceptions import PreventUpdate from dash.dependencies import Input, Output, State import dash_html_components as html import dash_core_components as dcc -import webviz_core_components as wcc +import webviz_subsurface_components as wsc from webviz_config import WebvizPluginABC from webviz_config.common_cache import CACHE from webviz_config.webviz_store import webvizstore @@ -128,7 +127,7 @@ def layout(self): self.make_buttons(self.ids("prev-btn"), self.ids("next-btn")), ], ), - wcc.Graph(id=self.ids("graph")), + wsc.PriorPosteriorDistribution(id=self.ids("graph")), ], ) @@ -154,25 +153,24 @@ def _set_parameter_from_btn(_prev_click, _next_click, column): return column @app.callback( - Output(self.ids("graph"), "figure"), [Input(self.ids("parameter"), "value")] + Output(self.ids("graph"), "data"), [Input(self.ids("parameter"), "value")] ) def _set_parameter(column): param = self.parameters[[column, "REAL", "ENSEMBLE"]] - plot = px.histogram( - param, - x=column, - y="REAL", - color="ENSEMBLE", - hover_data=["REAL"], - barmode="overlay", - nbins=10, - range_x=[param[column].min(), param[column].max()], - marginal="box", - template=self.plotly_theme, - ).for_each_trace(lambda t: t.update(name=t.name.replace("ENSEMBLE=", ""))) - - return plot + ensembles = param["ENSEMBLE"].unique().tolist() + + iterations = [] + values = [] + labels = [] + + for ensemble in ensembles: + df = param[param["ENSEMBLE"] == ensemble] + iterations.append(ensemble) + values.append(df[column].tolist()) + labels.append([f"Realization {real}" for real in df["REAL"].tolist()]) + + return {"iterations": iterations, "values": values, "labels": labels} def add_webvizstore(self): return [