Is it possible to define y_units of a glyph to be canvas (so they won't move vertically on pan/zoom)

I have time-series plots displayed and on the the plot I want to add a representation of different “Events” happened.

I think that the best way to visualize events is with circle glyph which will show event information with Hover tool.

Yet “events” don’t have Y value (only their time), so the best way would be to have a constant Y location on plot and move them only on X (when the plot is moved/zooms).

This can be achieved with Labels and I wonder if the same can somehow be applied for Glyphs.

Thanks

Hi Meir,

it is not possible to position glyphs directly using screen coordinates. Alternatively, you could use a secondary y-axis (https://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes) and use a callback to always reset the secondary y-axis range. Something like this:

p.add_layout(LinearAxis(y_range_name=‘events’, axis_label=‘Events’), ‘right’)

p.extra_y_ranges = {‘events’: Range1d(start=0, end=1)}

make sure you have ‘events_y’ in your CDS perhaps a list filled with ‘0.5’

p.circle(x=‘time’, y=‘events_y’, y_range_name=‘events’, source=cds, size=20)

This callback is used to reset the range of the secondary y-axis range

to its original value

args = {‘range’: p.extra_y_ranges[‘events’]}

code = “”"
range.start = 0;
range.end = 1;
“”"

callback = CustomJS(args=args, code=code)

p.extra_y_ranges[‘events’].js_on_change(‘start’, callback)

best,

···

On Mon, Apr 23, 2018 at 3:02 AM, Meir Tseitlin [email protected] wrote:

I have time-series plots displayed and on the the plot I want to add a representation of different “Events” happened.

I think that the best way to visualize events is with circle glyph which will show event information with Hover tool.

Yet “events” don’t have Y value (only their time), so the best way would be to have a constant Y location on plot and move them only on X (when the plot is moved/zooms).

This can be achieved with Labels and I wonder if the same can somehow be applied for Glyphs.

Thanks

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/f47a2f6f-ad9f-458e-9b38-dceca8e5ce72%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Angelo Fausti

Hi,

This used to be possible a very long time ago, but as features for more advanced hit testing and hover, etc were added, it had to be removed. Basically trying to hit test when coordinates could be in data space or screen space or a mix was just an unmanageable nightmare. The compromise we came up with was that Annotations were things that could be positioned directly in screen space, but that they would not participate in hit-testing. The thing desired here sounds a bit like a "Rug" annotation, which I've thought would be a nice addition for some time, so feel free to make an issue to discuss it. I don't think would be a ton of work and possibly a nice task for a new contributor.

Thanks,

Bryan

···

On Apr 23, 2018, at 10:07, Angelo Fausti <[email protected]> wrote:

Hi Meir,

it is not possible to position glyphs directly using screen coordinates. Alternatively, you could use a secondary y-axis (https://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes\) and use a callback to always reset the secondary y-axis range. Something like this:

p.add_layout(LinearAxis(y_range_name='events', axis_label='Events'), 'right')

p.extra_y_ranges = {'events': Range1d(start=0, end=1)}

# make sure you have 'events_y' in your CDS perhaps a list filled with '0.5'

p.circle(x='time', y='events_y', y_range_name='events', source=cds, size=20

# This callback is used to reset the range of the secondary y-axis range
# to its original value

args = {'range': p.extra_y_ranges['events']}

code = """
range.start = 0;
range.end = 1;
"""

callback = CustomJS(args=args, code=code)

p.extra_y_ranges['events'].js_on_change('start', callback)

best,

Angelo Fausti

On Mon, Apr 23, 2018 at 3:02 AM, Meir Tseitlin <[email protected]> wrote:
I have time-series plots displayed and on the the plot I want to add a representation of different "Events" happened.

I think that the best way to visualize events is with circle glyph which will show event information with Hover tool.

Yet "events" don't have Y value (only their time), so the best way would be to have a constant Y location on plot and move them only on X (when the plot is moved/zooms).

This can be achieved with Labels and I wonder if the same can somehow be applied for Glyphs.

Thanks

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/f47a2f6f-ad9f-458e-9b38-dceca8e5ce72%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5MH52MpZTiDHzap%3DcbTo_EdJSViW5wgr5%3D8gew2AmLHrw%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.