web-client-ui icon indicating copy to clipboard operation
web-client-ui copied to clipboard

Histogram ignores `xmax` if `xmax` is greater than the largest `x` value being plotted

Open alexpeters1208 opened this issue 2 years ago • 2 comments

Description

Histograms created with plot_xy_hist do not extend their x-axis to xmax if this value is larger than the maximum x value present in the dataset.

Steps to reproduce

Run this code:

from deephaven.plot.figure import Figure
from deephaven import new_table
from deephaven.column import int_col

source = new_table([
    int_col("Values", [1, 2, 2, 3, 3, 3, 4, 4, 5])
])

new_plot = Figure()\
    .plot_xy_hist(series_name="Histogram Values", t=source, x="Values", nbins=5, xmin=0.0, xmax=10.0)\
    .chart_title(title="Histogram of Values")\
    .show()

Expected results

I expect this histogram to have data between 1 and 5, and an x-axis that extends out to 10.

Actual results

The axis stops at 6. It seems to want to obey nbins, and is binning the data as though the plot extends out to 10, but only non-zero bins are being shown, so there are fewer nbins than requested.

Screenshot 2023-12-05 at 10 29 59 AM

Versions

  • Deephaven: 0.30.1
  • OS: MacOS
  • Browser: Safari

alexpeters1208 avatar Dec 05 '23 16:12 alexpeters1208

I think the API may be confusing - this is a maximum x value, not the maximum x range to show in the rendered plot. Even the example in the docs shows an example with nbins=5 and only 3 bins show up: https://deephaven.io/core/docs/how-to-guides/plotting/histogram/#from-a-table image

mofojed avatar Dec 12 '23 16:12 mofojed

I think the API may be confusing - this is a maximum x value, not the maximum x range to show in the rendered plot. Even the example in the docs shows an example with nbins=5 and only 3 bins show up: https://deephaven.io/core/docs/how-to-guides/plotting/histogram/#from-a-table image

Yep, I'd say that is a confusing API and not what I expected / wanted. Not sure what the resolution here should be.

alexpeters1208 avatar Dec 15 '23 18:12 alexpeters1208