-
Notifications
You must be signed in to change notification settings - Fork 132
Disable log scale when value is within 0.1 of zero for Histograms #13496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we remove this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since so I don't think min can be equal to max in |
||
| if use_log_scale: | ||
| bins = _histogramLogBins(effective_bin_count, minimum, maximum) # type: ignore | ||
| axes.set_xscale("log") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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]}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we extract this as a constant, like @eqbech proposed? |
||
| return pd.DataFrame({0: [-0.1, -0.5, -0.9]}) | ||
|
|
||
| mock_plot_api.data_for_parameter.side_effect = mock_data_for_parameter | ||
|
|
@@ -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, | ||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?