Skip to content
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

redim.range doesn't work when using special kdim name #3205

Closed
flothesof opened this issue Nov 27, 2018 · 3 comments
Closed

redim.range doesn't work when using special kdim name #3205

flothesof opened this issue Nov 27, 2018 · 3 comments

Comments

@flothesof
Copy link
Contributor

flothesof commented Nov 27, 2018

Hi,
I've recently (in #1717) found out that I can resize the axes ranges of elements like this:

# imports
import holoviews as hv
hv.extension('bokeh')
import numpy as np

# data
t = np.arange(0, 10, 0.1)
x = np.sin(2 * np.pi * .5 * t)

# first plot that works well
c = hv.Curve((t, x), kdims='time')
c.redim.range(time=(0, 5))

Since I want custom units, for instance µseconds, I thought this might work as well if I use kdims='time in µs' and then create a reference to my Dimension instance:

# second plot that doesn't work
c1 = hv.Curve((t, x), kdims='time in µs')
tdim = c1.dimensions()[0]
c1.redim.range(tdim=(0, 5))

However, this simply returns the full curve going from 0 to 10 and not just from 0 to 5.

Am I doing something wrong or is this a bug?

Thanks for your help
Florian

@ahuang11
Copy link
Collaborator

ahuang11 commented Nov 28, 2018

# imports
import holoviews as hv
hv.extension('bokeh')
import numpy as np

# data
t = np.arange(0, 10, 0.1)
x = np.sin(2 * np.pi * .5 * t)

# first plot that works well
c = hv.Curve((t, x), kdims=('time', 'time in µs'))  # assign a label to the kdim
c.redim.range(time=(0, 5))  # use the kdim

Or

# imports
import holoviews as hv
hv.extension('bokeh')
import numpy as np

# data
t = np.arange(0, 10, 0.1)
x = np.sin(2 * np.pi * .5 * t)

# first plot that works well
label = 'time in µs'
c = hv.Curve((t, x), kdims=label)  # make the kdim == label
c.redim.range(**{label: (0, 5)})  # use python syntax to unpack dictionary since it has spaces

Or new on master/eventual 1.11

# imports
import holoviews as hv
hv.extension('bokeh')
import numpy as np

# data
t = np.arange(0, 10, 0.1)
x = np.sin(2 * np.pi * .5 * t)

# first plot that works well
label = 'time in µs'
c = hv.Curve((t, x))
c.options(xlabel=label)  # override the existing label

I think the FAQ will be updated soon with v1.11
https://github.com/ioam/holoviews/blob/master/doc/FAQ.rst

@xavArtley
Copy link

xavArtley commented Nov 28, 2018

@flothesof
Your code was almost valid :

# second plot that doesn't work
c1 = hv.Curve((t, x), kdims='time in µs')
tdim = c1.dimensions()[0]
tdim.range = (0,5) #c1.redim.range(tdim=(0, 5))
c1

would have done the trick

@jbednar jbednar closed this as completed Nov 28, 2018
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants