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

Spikes element does not overlay properly #1539

Open
jlstevens opened this issue Jun 14, 2017 · 9 comments
Open

Spikes element does not overlay properly #1539

jlstevens opened this issue Jun 14, 2017 · 9 comments
Assignees
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@jlstevens
Copy link
Contributor

As shown here:

image

I get the same issue with matplotlib.

@jlstevens jlstevens added the type: bug Something isn't correct or isn't working label Jun 14, 2017
@philippjfr philippjfr added this to the v1.8 milestone Jun 15, 2017
@philippjfr philippjfr modified the milestones: v1.9, v1.8 Jun 27, 2017
@jlstevens
Copy link
Contributor Author

Actually, this issue may be a duplicate of the issue described in #1480.

@jlstevens
Copy link
Contributor Author

Looks like it is fixed?

image

This screenshot shows a different issue (unexpected colormapping) described in #1669.

@philippjfr
Copy link
Member

I'm not sure this was ever a real issue, it's just to do with the semantics of Spikes. By default Spikes do not have a height so you have to set the height as a plot option. In the plot above the height of the Spikes is likely just too small to see. In your new example you have given them a height so there is no issue.

@jlstevens
Copy link
Contributor Author

Philipp and I discussed this about maybe the height plot options should be 1 by default as a relative quantity (fraction of the y-axis). That would make more sense to me I think.

@philippjfr philippjfr self-assigned this Sep 23, 2017
@philippjfr philippjfr modified the milestones: v1.9, v1.10 Oct 22, 2017
@philippjfr philippjfr modified the milestones: v1.10, v2.0 Mar 3, 2018
@neighthan
Copy link

neighthan commented Mar 7, 2019

@jlstevens I agree. I just learned that VLine can't appear in the legend, so I replaced it with Spikes in my code. However, it's not easy to get spikes that overlay properly when I want them to be the full height of the plot. Now I have to modify my spikes based on what I'm overlaying them with, which isn't nice. Unless explicit heights are given, I think having full-height spikes is the most reasonable default. These are the two workarounds I've found for getting a full-height vertical line that also appears (more or less) in the legend

import numpy as np
import holoviews as hv
hv.extension("bokeh")

x = np.linspace(0, 1)
curve = hv.Curve((x, np.sin(x)), label="sin(x)")
height = curve.data["y"].max() - curve.data["y"].min()
spikes = hv.Spikes(([0.5], [height]), vdims="height", label="mid")
spikes * curve

image

# need to make sure the colors are the same for spikes/vlines
# would look a bit better if I adjusted the spike thickness too
spikes = hv.Spikes([0.5], label="mid").opts(color="black")
vline = hv.VLine(0.5).opts(color="black")

spikes * curve * vline

image

@SandervandenOord
Copy link

SandervandenOord commented Jan 18, 2020

Philipp and I discussed this about maybe the height plot options should be 1 by default as a relative quantity (fraction of the y-axis). That would make more sense to me I think.

Is there already something like relative spike_length, so you don't have to think yourself about what absolute length the spikes should get?
Right now I would do something like scatter * spikes.opts(spike_length='very large number') to be sure it goes over the whole y range of scatter. Edit: I thought this would work, but y-axis just gets the spike range, so this is also not a workaround.
But it would also be nice when you just put the spikes to be at 25% of the y-range?

@jlstevens
Copy link
Contributor Author

@philippjfr I'm wondering if there is a way to use the dim object to find the y-range and scale as a proportion of that. Should be possible, right?

@philippjfr
Copy link
Member

I'm not sure if spike_length accepts a dim transform atm but in theory that should be possible yes. Something like:

spike_length=np.ptp(dim('y'))/10.

@philippjfr
Copy link
Member

Actually no that doesn't make sense, that would just get the range of the y-values, not the overall range of the plot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

4 participants