Linked Panning on multiple Twin Axes plots?

Hi, is it possible to perform linked panning on multiple twin axes plots?

Horizontal panning works fine since there’s only one x axis, but I’m stuck regarding how to get vertical panning to work for both the primary and second y axis plots. Running the sample code below and then panning up and down will make what I’m trying to describe much clearer.

Referencing the documentation from here:

Linked Panning: https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/linking.html#linked-panning

Twin Axes: https://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes

Extending on the twin axes example, here’s what I’m trying to do:

from numpy import pi, arange, sin, linspace

from bokeh.plotting import figure, show
from bokeh.models import LinearAxis, Range1d
from bokeh.layouts import gridplot
from bokeh.io import output_notebook
output_notebook()

x = arange(-2pi, 2pi, 0.1)
y1 = sin(x)
y2 = linspace(0, 100, len(y))

Plot 1

p1 = figure(x_range=(-6.5, 6.5), y_range=(-1.1, 1.1))

p1.circle(x, y1, color=“red”)

p1.extra_y_ranges = {“foo”: Range1d(start=0, end=100)}
p1.circle(x, y2, color=“blue”, y_range_name=“foo”)
p1.add_layout(LinearAxis(y_range_name=“foo”), ‘right’)

Plot 2

p2 = figure(x_range=p1.x_range, y_range=p1.y_range) # linked to p1

p2.circle(x, y1, color=“red”)

p2.extra_y_ranges = {“foo”: Range1d(start=0, end=100)} # how to link this part???
p2.circle(x, y2, color=“blue”, y_range_name=“foo”)
p2.add_layout(LinearAxis(y_range_name=“foo”), ‘right’)

show(gridplot([[p1], [p2]], plot_width=900, plot_height=300, toolbar_location=‘above’))

``

Sorry, small typo…

Original:

y2 = linspace(0, 100, len(y))

``

Should be:

y2 = linspace(0, 100, len(y1)) # changed to y1

``

···

On Saturday, December 8, 2018 at 10:34:05 PM UTC+2, Scott Pritchard wrote:

Hi, is it possible to perform linked panning on multiple twin axes plots?

Horizontal panning works fine since there’s only one x axis, but I’m stuck regarding how to get vertical panning to work for both the primary and second y axis plots. Running the sample code below and then panning up and down will make what I’m trying to describe much clearer.

Referencing the documentation from here:

Linked Panning: https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/linking.html#linked-panning

Twin Axes: https://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes

Extending on the twin axes example, here’s what I’m trying to do:

from numpy import pi, arange, sin, linspace

from bokeh.plotting import figure, show
from bokeh.models import LinearAxis, Range1d
from bokeh.layouts import gridplot
from bokeh.io import output_notebook
output_notebook()

x = arange(-2pi, 2pi, 0.1)
y1 = sin(x)
y2 = linspace(0, 100, len(y))

Plot 1

p1 = figure(x_range=(-6.5, 6.5), y_range=(-1.1, 1.1))

p1.circle(x, y1, color=“red”)

p1.extra_y_ranges = {“foo”: Range1d(start=0, end=100)}
p1.circle(x, y2, color=“blue”, y_range_name=“foo”)
p1.add_layout(LinearAxis(y_range_name=“foo”), ‘right’)

Plot 2

p2 = figure(x_range=p1.x_range, y_range=p1.y_range) # linked to p1

p2.circle(x, y1, color=“red”)

p2.extra_y_ranges = {“foo”: Range1d(start=0, end=100)} # how to link this part???
p2.circle(x, y2, color=“blue”, y_range_name=“foo”)
p2.add_layout(LinearAxis(y_range_name=“foo”), ‘right’)

show(gridplot([[p1], [p2]], plot_width=900, plot_height=300, toolbar_location=‘above’))

``

It seems that all that was required was the following:

p2.extra_y_ranges = p1.extra_y_ranges

``

Bonus points if anyone can tell me how to draw a Span (horizontal line) to a location on the secondary y axis.

···

On Saturday, December 8, 2018 at 10:34:05 PM UTC+2, Scott Pritchard wrote:

Hi, is it possible to perform linked panning on multiple twin axes plots?

Horizontal panning works fine since there’s only one x axis, but I’m stuck regarding how to get vertical panning to work for both the primary and second y axis plots. Running the sample code below and then panning up and down will make what I’m trying to describe much clearer.

Referencing the documentation from here:

Linked Panning: https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/linking.html#linked-panning

Twin Axes: https://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes

Extending on the twin axes example, here’s what I’m trying to do:

from numpy import pi, arange, sin, linspace

from bokeh.plotting import figure, show
from bokeh.models import LinearAxis, Range1d
from bokeh.layouts import gridplot
from bokeh.io import output_notebook
output_notebook()

x = arange(-2pi, 2pi, 0.1)
y1 = sin(x)
y2 = linspace(0, 100, len(y))

Plot 1

p1 = figure(x_range=(-6.5, 6.5), y_range=(-1.1, 1.1))

p1.circle(x, y1, color=“red”)

p1.extra_y_ranges = {“foo”: Range1d(start=0, end=100)}
p1.circle(x, y2, color=“blue”, y_range_name=“foo”)
p1.add_layout(LinearAxis(y_range_name=“foo”), ‘right’)

Plot 2

p2 = figure(x_range=p1.x_range, y_range=p1.y_range) # linked to p1

p2.circle(x, y1, color=“red”)

p2.extra_y_ranges = {“foo”: Range1d(start=0, end=100)} # how to link this part???
p2.circle(x, y2, color=“blue”, y_range_name=“foo”)
p2.add_layout(LinearAxis(y_range_name=“foo”), ‘right’)

show(gridplot([[p1], [p2]], plot_width=900, plot_height=300, toolbar_location=‘above’))

``

Hi,

Spans have x/y range name properties the same as glyphs do:

  annotations — Bokeh 3.3.2 Documentation

I would not have expected having to share the extra ranges to get planned panning working offhand, though I think I can possibly imagine why it would be necessary currently. AFAIK you are the first person to have tried this.

Thanks,

Bryan

···

On Dec 9, 2018, at 03:27, Scott Pritchard <[email protected]> wrote:

It seems that all that was required was the following:

p2.extra_y_ranges = p1.extra_y_ranges

Bonus points if anyone can tell me how to draw a Span (horizontal line) to a location on the secondary y axis.

On Saturday, December 8, 2018 at 10:34:05 PM UTC+2, Scott Pritchard wrote:
Hi, is it possible to perform linked panning on multiple twin axes plots?

Horizontal panning works fine since there's only one x axis, but I'm stuck regarding how to get vertical panning to work for both the primary and second y axis plots. Running the sample code below and then panning up and down will make what I'm trying to describe much clearer.

Referencing the documentation from here:
Linked Panning: Linked behavior — Bokeh 3.3.2 Documentation
Twin Axes: https://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes

Extending on the twin axes example, here's what I'm trying to do:

from numpy import pi, arange, sin, linspace

from bokeh.plotting import figure, show
from bokeh.models import LinearAxis, Range1d
from bokeh.layouts import gridplot
from bokeh.io import output_notebook
output_notebook()

x = arange(-2*pi, 2*pi, 0.1)
y1 = sin(x)
y2 = linspace(0, 100, len(y))

# Plot 1
p1 = figure(x_range=(-6.5, 6.5), y_range=(-1.1, 1.1))

p1.circle(x, y1, color="red")

p1.extra_y_ranges = {"foo": Range1d(start=0, end=100)}
p1.circle(x, y2, color="blue", y_range_name="foo")
p1.add_layout(LinearAxis(y_range_name="foo"), 'right')

# Plot 2
p2 = figure(x_range=p1.x_range, y_range=p1.y_range) # linked to p1

p2.circle(x, y1, color="red")

p2.extra_y_ranges = {"foo": Range1d(start=0, end=100)} # how to link this part???
p2.circle(x, y2, color="blue", y_range_name="foo")
p2.add_layout(LinearAxis(y_range_name="foo"), 'right')

show(gridplot([[p1], [p2]], plot_width=900, plot_height=300, toolbar_location='above'))

--
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/4be411eb-5a5a-485f-93ac-6e198dd0fbdd%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Ah, didn’t realize that. Works beautifully, thank you!

···

On Sunday, December 9, 2018 at 8:29:25 PM UTC+2, Bryan Van de ven wrote:

Hi,

Spans have x/y range name properties the same as glyphs do:

    [https://bokeh.pydata.org/en/latest/docs/reference/models/annotations.html#bokeh.models.annotations.Span](https://bokeh.pydata.org/en/latest/docs/reference/models/annotations.html#bokeh.models.annotations.Span)

I would not have expected having to share the extra ranges to get planned panning working offhand, though I think I can possibly imagine why it would be necessary currently. AFAIK you are the first person to have tried this.

Thanks,

Bryan

On Dec 9, 2018, at 03:27, Scott Pritchard [email protected] wrote:

It seems that all that was required was the following:

p2.extra_y_ranges = p1.extra_y_ranges

Bonus points if anyone can tell me how to draw a Span (horizontal line) to a location on the secondary y axis.

On Saturday, December 8, 2018 at 10:34:05 PM UTC+2, Scott Pritchard wrote:

Hi, is it possible to perform linked panning on multiple twin axes plots?

Horizontal panning works fine since there’s only one x axis, but I’m stuck regarding how to get vertical panning to work for both the primary and second y axis plots. Running the sample code below and then panning up and down will make what I’m trying to describe much clearer.

Referencing the documentation from here:

Linked Panning: https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/linking.html#linked-panning

Twin Axes: https://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#twin-axes

Extending on the twin axes example, here’s what I’m trying to do:

from numpy import pi, arange, sin, linspace

from bokeh.plotting import figure, show

from bokeh.models import LinearAxis, Range1d

from bokeh.layouts import gridplot

from bokeh.io import output_notebook

output_notebook()

x = arange(-2pi, 2pi, 0.1)

y1 = sin(x)

y2 = linspace(0, 100, len(y))

Plot 1

p1 = figure(x_range=(-6.5, 6.5), y_range=(-1.1, 1.1))

p1.circle(x, y1, color=“red”)

p1.extra_y_ranges = {“foo”: Range1d(start=0, end=100)}

p1.circle(x, y2, color=“blue”, y_range_name=“foo”)

p1.add_layout(LinearAxis(y_range_name=“foo”), ‘right’)

Plot 2

p2 = figure(x_range=p1.x_range, y_range=p1.y_range) # linked to p1

p2.circle(x, y1, color=“red”)

p2.extra_y_ranges = {“foo”: Range1d(start=0, end=100)} # how to link this part???

p2.circle(x, y2, color=“blue”, y_range_name=“foo”)

p2.add_layout(LinearAxis(y_range_name=“foo”), ‘right’)

show(gridplot([[p1], [p2]], plot_width=900, plot_height=300, toolbar_location=‘above’))


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/4be411eb-5a5a-485f-93ac-6e198dd0fbdd%40continuum.io.

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