holoviz / datashader

Quickly and accurately render even the largest data.
http://datashader.org
BSD 3-Clause "New" or "Revised" License
3.3k stars 365 forks source link

Expose computed bounds after aggregation #1157

Closed muendlein closed 1 year ago

muendlein commented 1 year ago

Currently the data bounds will computed during aggregation if the x or y ranges are not provided explicitely:

canvas = ds.Canvas(plot_width=300, plot_height=300, x_axis_type='linear', y_axis_type='linear')
aggregation = canvas.points(df, 'x', 'y', agg=ds.count())

However those computed ranges do not seem to get exposed and are thus not really accessible. Nevertheless they are quite important when displaying the data. Thus I propose to utilize the attrs field of the xarray.DataArray (which can hold arbitrary metadata) to provide the (computed) ranges. Essentially I want to get the following:

x_range = aggregation.attrs["x_range"]
y_range = aggregation.attrs["y_range"]
ianthomas23 commented 1 year ago

Thanks @muendlein, that is a good idea. I'd would be inclined to set the new range attributes regardless of whether they are computed or set by the user.

muendlein commented 1 year ago

@ianthomas23 Agreed