question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image should warn about unevenly spaced dimensions

See original GitHub issue

Gridded 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 image

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)

image all the grid boxes are the same size.

Am I missing something obvious?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:27 (24 by maintainers)

github_iconTop GitHub Comments

2reactions
rabernatcommented, Sep 13, 2017

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.

I would rather make the expectation of even sampling clear to the user

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.

1reaction
philippjfrcommented, Dec 11, 2017

Yes, that’s the goal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Elements of Visual Interpretation
Orchards with evenly spaced trees, and urban streets with regularly spaced houses are good examples of pattern. Texture refers to the ...
Read more >
Perspective warp in Photoshop - Adobe Support
Sometimes, an object may look different in an image from how it appears in real life. This mismatch is due to perspective distortion....
Read more >
How to space images evenly throughout a page?
If you want to have images have width and height are set to 400px , you can use display: flex and set its...
Read more >
Principles of Image Analysis | SpringerLink
Finally, image analysis software measures area fraction and size distribution of nodules, providing data that can be used to compare against ...
Read more >
5 PowerPoint Image Placement Tips: How to Be Exact
When you have a bunch of images on a slide, it's more pleasing to the eye when they are spaced out evenly. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found