-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
Warn about setting vdims on NdMapping types #811
Comments
It sounds like you are looking for what we call 'value dimensions'. Something like: hv.Image(data, kdims=['X','Y'], vdims=[hv.Dimension('Data', range=(-1,1))]) I believe that specifying the |
Hi @jlstevens. Thanks for the suggestion. It doesn't seem to do what I want, unfortunately - you can see this in this example: %%opts Image style(interpolation='nearest')[colorbar=True]
import numpy as np
import holoviews as hv
hv.notebook_extension()
x,y = np.mgrid[-50:51, -50:51] * 0.1
def sine_image(freq):
return hv.Image(np.sin(freq*x**2+freq*y**2)**2)
dmap = hv.DynamicMap(sine_image, kdims=[hv.Dimension('frequency', range=(0, np.pi))],
vdims=[hv.Dimension('data', range=(0, 1))])
dmap If you adjust the value of the frequency parameter, you can see that the colourbar changes: |
I think it therefore may be the case that the description of the data isn't taken into account in the colourbar plotting? |
Does it change only for freq=0? If so it could just be that the colorbar has a default for plots with no color range (as freq=0 means that it's a constant plot, with no changes over x and y). |
The DynamicMap itself does not have any vdims, so declaring it like you did here has no effect: dmap = hv.DynamicMap(sine_image, kdims=[hv.Dimension('frequency', range=(0, np.pi))],
vdims=[hv.Dimension('data', range=(0, 1))]) What you presumably want is this: def sine_image(freq):
return hv.Image(np.sin(freq*x**2+freq*y**2)**2,
vdims=[hv.Dimension('data', range=(0, 1))]) |
You are right, I wasn't thinking. As Philipp indicates, the vdim range needs to be on the element returned by the |
Actually, this looks like another place we could issue a warning to prevent confusion. I don't think a |
I just noticed that in my original comment, I did suggest setting the vdims on I think my point about issuing a warning if vdims are set on |
I've repurposed this issue to remind us to raise the appropriate warning. |
Agreed. Issuing a warning shouldn't be much work so I've assigned this to the 1.7 milestone. |
NdMapping types will now raise an exception when setting vdims, closing. |
Thanks a lot! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm having trouble with visualising some data files, and I was just wondering if anyone can help.
I've got a large number of data files, and the data is on a regular grid that can be displayed using hv.Image. For simplicity, we can say that the for each data is represented by some function f(x, y, p). In advance we know that the bounds of f(x, y, p) for all values of p are [-1, 1], but for any given data file the bounds might be some narrower region of that range, because p changes the function. However, I still want to set the colourbar range between the bounds [-1, 1] even if, for some given set of data, the bounds are only something like [-0.5, 0.5].
I'm not sure where to look in Holoviews to try and do this - it seems to me that this is linked in with the data side rather than the visualisation side, because it's intrinsically linked to the function f mathematically. However, I can't see an option in the help to specify the data bounds. Ideally, I'd have thought there'd be some kind of parameter, similar to extent, which allows an overwrite the data range - something like how bounds works:
The text was updated successfully, but these errors were encountered: