diff --git a/src/ert/gui/tools/plot/plot_widget.py b/src/ert/gui/tools/plot/plot_widget.py index 00792acd0ab..76a85e986ac 100644 --- a/src/ert/gui/tools/plot/plot_widget.py +++ b/src/ert/gui/tools/plot/plot_widget.py @@ -203,7 +203,7 @@ def __init__( vbox.addSpacing(8) self.setLayout(vbox) - self._negative_values_in_data = False + self._negative_or_non_unique_values_in_data = False self.resetPlot() @property @@ -221,7 +221,7 @@ def _sync_log_checkbox(self, key_def: PlotApiKeyDefinition | None = None) -> Non "DistributionPlot", "GaussianKDEPlot", } - and self._negative_values_in_data is False + and self._negative_or_non_unique_values_in_data is False ): if key_def is not None: a = key_def.parameter @@ -271,7 +271,7 @@ def updatePlot( plot_context.log_scale = ( self._log_checkbox.isVisible() and self._log_checkbox.isChecked() - and self._negative_values_in_data is False + and self._negative_or_non_unique_values_in_data is False ) plot_context.extended_plot_information = ( self._extended_plot_information_checkbox.isVisible() diff --git a/src/ert/gui/tools/plot/plot_window.py b/src/ert/gui/tools/plot/plot_window.py index 1936bbd9a86..75a60a15cc5 100644 --- a/src/ert/gui/tools/plot/plot_window.py +++ b/src/ert/gui/tools/plot/plot_window.py @@ -415,15 +415,22 @@ def fetch_data( elif result is not None: ensemble_to_data_map[ensemble] = result - negative_values_in_data = False + negative_or_non_unique_values_in_data = False 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(): - negative_values_in_data = True + # Need non-unique check to disable log scale for + # single realization runs, even though the + # distribution is not set as CONSTANT + if not numeric.empty and ( + numeric.le(0).any().any() or numeric.nunique().le(1).all() + ): + negative_or_non_unique_values_in_data = True break - plot_widget._negative_values_in_data = negative_values_in_data + plot_widget._negative_or_non_unique_values_in_data = ( + negative_or_non_unique_values_in_data + ) observations = pd.DataFrame() if key_def.observations and selected_ensembles: try: diff --git a/src/ert/gui/tools/plot/plottery/plots/histogram.py b/src/ert/gui/tools/plot/plottery/plots/histogram.py index 5bd0e9c1a3a..5e91a88c8f3 100644 --- a/src/ert/gui/tools/plot/plottery/plots/histogram.py +++ b/src/ert/gui/tools/plot/plottery/plots/histogram.py @@ -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 if use_log_scale: bins = _histogramLogBins(effective_bin_count, minimum, maximum) # type: ignore axes.set_xscale("log")