Skip to content

Commit 00dba8b

Browse files
Fix: Inaccurate visualization of parameter distributions (#1327)
* Fix: Inaccurate visualization of parameter distributions
1 parent 05eae3b commit 00dba8b

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Added
1212
- [#1297](https://github.com/equinor/webviz-subsurface/pull/1297) - Added mean for mc sensitivities in the tornadotable in `VolumetricAnalysis`.
13-
13+
- [#1327](https://github.com/equinor/webviz-subsurface/pull/1327) - Added histograms to parameter distributions in `ParameterAnalysis`.
1414
## [0.2.30] - 2024-06-10
1515

1616
### Added

webviz_subsurface/plugins/_parameter_analysis/_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
class VisualizationType(StrEnum):
5+
HISTOGRAM = "histogram"
56
DISTRIBUTION = "distribution"
67
BOX = "box"
78
STAT_TABLE = "stat-table"

webviz_subsurface/plugins/_parameter_analysis/_utils/_parameters_model.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from webviz_subsurface._figures import create_figure
99
from webviz_subsurface._models.parameter_model import ParametersModel as Pmodel
1010

11+
from .._types import VisualizationType
12+
1113

1214
class ParametersModel:
1315
"""Class to process and visualize ensemble parameter data"""
@@ -163,22 +165,23 @@ def make_grouped_plot(
163165
self,
164166
ensembles: list,
165167
parameters: List[Any],
166-
plot_type: str = "distribution",
168+
plot_type: VisualizationType = VisualizationType.DISTRIBUTION,
167169
) -> go.Figure:
168170
"""Create subplots for selected parameters"""
169171
df = self.dataframe_melted.copy()
170172
df = df[df["ENSEMBLE"].isin(ensembles)]
171173
df = df[df["PARAMETER"].isin(parameters)]
172174
df = self._sort_parameters_col(df, parameters)
173175

174-
return (
176+
figure = (
175177
create_figure(
176178
plot_type=plot_type,
177179
data_frame=df,
178180
x="VALUE",
179181
facet_col="PARAMETER",
180182
color="ENSEMBLE",
181183
color_discrete_sequence=self.colorway,
184+
barmode="overlay",
182185
)
183186
.update_xaxes(matches=None)
184187
.for_each_trace(
@@ -189,6 +192,11 @@ def make_grouped_plot(
189192
)
190193
)
191194
)
195+
# Use bingroup=None so that Plotly calculates bins per trace
196+
# This also means that individual ensembles will have separate binning.
197+
if plot_type == VisualizationType.HISTOGRAM:
198+
figure.update_traces(bingroup=None)
199+
return figure
192200

193201
def get_stat_value(self, parameter: str, ensemble: str, stat_column: str) -> float:
194202
"""

webviz_subsurface/plugins/_parameter_analysis/_views/_parameter_distributions_view/_settings/_visualization_type.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def layout(self) -> List[Component]:
2020
wcc.RadioItems(
2121
id=self.register_component_unique_id(self.Ids.VISUALIZATION_TYPE),
2222
options=[
23+
{"label": "Histogram", "value": VisualizationType.HISTOGRAM},
2324
{
2425
"label": "Distribution plots",
2526
"value": VisualizationType.DISTRIBUTION,
@@ -30,7 +31,7 @@ def layout(self) -> List[Component]:
3031
"value": VisualizationType.STAT_TABLE,
3132
},
3233
],
33-
value=VisualizationType.DISTRIBUTION,
34+
value=VisualizationType.HISTOGRAM,
3435
vertical=True,
3536
)
3637
]

0 commit comments

Comments
 (0)