Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/ert/gui/tools/plot/plot_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ def fetch_data(
if key_def.parameter is not None and key_def.parameter.type == "gen_kw":
for data in ensemble_to_data_map.values():
numeric = data.select_dtypes(include=["number"])
if not numeric.empty and numeric.le(0).any().any():
# Use 0.11 instead of 0 because the histogram
# expands the range by ±0.1 when min == max,
# which would make a value of 0.1 become a negative bin edge.
if not numeric.empty and numeric.lt(0.11).any().any():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we should do this to compensate for a magic number we set somewhere else. I think the solution should be to dynamically calculate the width of the bars so they wont be <=0 on the plotter side instead of hardcoded 0.5+0.5.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this to <= 0 and do the bin calculation in the plot such that a bin edge can never be <= 0 instead?

negative_values_in_data = True
break

Expand Down
3 changes: 0 additions & 3 deletions src/ert/gui/tools/plot/plottery/plots/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ def _plotHistogram(
if minimum is not None and maximum is not None:
# Ensure we have at least 2 bin edges to create 1 bin
effective_bin_count = max(bin_count + 1, 2)
if minimum == maximum:
minimum -= 0.5
maximum += 0.5
Comment on lines -191 to -193
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we remove this?

Copy link
Copy Markdown
Contributor Author

@eilskra eilskra May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since plotHistogram() calls _plotHistogram() and prior to _plotHistogram() being called the min/max transformation is checked/applied:

if minimum is not None and maximum is not None and minimum == maximum:
                    minimum -= 0.1
                    maximum += 0.1

so I don't think min can be equal to max in _plotHistogram

if use_log_scale:
bins = _histogramLogBins(effective_bin_count, minimum, maximum) # type: ignore
axes.set_xscale("log")
Expand Down
4 changes: 2 additions & 2 deletions tests/ert/unit_tests/gui/tools/plot/test_plot_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_that_plotting_gen_kw_parameter_with_negative_values_hides_log_scale_che

def mock_data_for_parameter(ensemble_id: str, parameter_key: str) -> pd.DataFrame:
if parameter_key == "gen_kw_a":
return pd.DataFrame({0: [0.1, 0.5, 0.9]})
return pd.DataFrame({0: [0.11, 0.5, 0.9]})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract this as a constant, like @eqbech proposed?
You could import this from plot_window.

return pd.DataFrame({0: [-0.1, -0.5, -0.9]})

mock_plot_api.data_for_parameter.side_effect = mock_data_for_parameter
Expand Down Expand Up @@ -313,7 +313,7 @@ def test_that_plot_widget_hides_log_scale_checkbox_for_const_distribution(qtbot:
)
plot_widget.updatePlot(
ctx,
{ensemble: pd.DataFrame({0: [0.1, 0.2, 0.3]})},
{ensemble: pd.DataFrame({0: [0.11, 0.2, 0.3]})},
pd.DataFrame(),
{},
None,
Expand Down
Loading