Image should warn about unevenly spaced dimensions
See original GitHub issueGridded scientific datasets commonly have dimensions that are unevenly spaced. (For example, an ocean temperature dataset has more vertical levels near the surface than in the deep.) We can easily visualize these datasets correctly with matlplotlib using a pcolormesh or contour plot. But I am unsure about the status of support for such datasets in holoviews. The documentation mentions support for irregularly sampled continuous coordinates, but I couldn’t find a clear example.
Here is an example of what I mean using xarray. Consider the following dataset
import xarray as xr
import numpy as np
# monotonically increasing but unevenly spaced coordinates
x = np.arange(20)**2
y = np.arange(10)**2
z = y[:,np.newaxis] * x
data = xr.DataArray(z,
dims=['y', 'x'],
coords={'y': y, 'x': x},
name='randomdata')
data.plot()
xarray renders this correctly, with grid boxes of variable size
However, in holoviews, the irregular spacing seems to be lost when I convert to image
import holoviews as hv
%%opts Image (cmap='viridis')
hv.Image(data)
all the grid boxes are the same size.
Am I missing something obvious?
Issue Analytics
- State:
- Created 6 years ago
- Comments:27 (24 by maintainers)
Top GitHub Comments
Hopefully I can offer some perspective as a new user. (BTW, thanks to all of the developers for your excellent and hard work on this amazing project.)
I am coming to holoviews as an experienced xarray user and developer. I wanted to bring my xarray data into holoviews, so I read the user guide on gridded datasets. In fact, the docs do not appear to have a direct example of how to do this. However the very first example said, “Let us start by declaring an Image with explicit x- and y-coordinates.” I recognized this as similar to xarray’s data model, so I tried creating an image from my xarray data as
hv.Image(data)
. It worked, as in there were no errors or warnings. However, I soon discovered that holoviews.Image was misrepresenting my data.This was most certainly not clear to me. There is an indirect reference to “regularly sampled arrays” in the getting started Gridded Data page, but the interpretation of “regular” is ambiguous. Morever, my thinking was why does Image even bother keeping track of explicit x- and y-coordinates if they are ignored in visualization? The option to pass explicit coordinates to
Image
creates the expectation that they will be respected.I think the solution is to actually forbid the creation of
Image
objects with explicit x and y coordinates if you don’t plan to render such images correctly.Yes, that’s the goal.