Bokeh RangeTool interaction between figures using different dimensions



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Following the example for the RangeTool here: https://bokeh.pydata.org/en/latest/docs/gallery/range_tool.html, I ran into some issues. I want to have the secondary plot's range tool brush the data on a dimension not displayed by the main plot (z in this example), and have the data in the main plot brushed according to the selection on the secondary plot. So I did the following:



import numpy as np
from bokeh.models import ColumnDataSource, RangeTool
from bokeh.layouts import column
from bokeh.plotting import figure, show

n = 10
x = np.random.random(n)
y = np.random.random(n)
z = np.arange(n)
source = ColumnDataSource(data=dict(x=x, y=y, z=z, xy=x+y))

plotxy = figure(plot_width=800, plot_height=800)
plotxy.scatter('x', 'y', source=source)

plotz = figure(plot_width=800, plot_height=100)
plotz.line('z', 'xy', source=source)
range_rool = RangeTool(x_range=plotz.x_range)
plotz.add_tools(range_rool)

p = column([plotxy, plotz])
show(p)


However, the RangeTool seems incompatible with this approach since I get:



expected an instance of type Range1d, got DataRange1d(id='13429', ...) of type DataRange1d


on the following row: range_rool = RangeTool(x_range=plotz.x_range).
Changing it to x_range=Range1d(z[0], z[-1]) makes everything appear correctly, but the brushing has no effect on the main figure.



I can get the interaction I want using this instead for the secondary figure:



plotz = figure(plot_width=800, plot_height=100, tools='xbox_select')
plotz.scatter('t', 'xy', source=source)
plotz.line('t', 'xy', source=source)


The problem here is that the BoxSelectionTool is not persistent and draggable, which is the key functionality I want to have.



Since the brushing works on the BoxSelectionTool perfectly, is this missing from the RangeTool API so this is impossible, or am I using the wrong approach here?
(PS. adding the scatter to the secondary figure has no effect on the RangeTool)



Is there any way to get this interaction behavior easily? Thanks.










share|improve this question




























    0















    Following the example for the RangeTool here: https://bokeh.pydata.org/en/latest/docs/gallery/range_tool.html, I ran into some issues. I want to have the secondary plot's range tool brush the data on a dimension not displayed by the main plot (z in this example), and have the data in the main plot brushed according to the selection on the secondary plot. So I did the following:



    import numpy as np
    from bokeh.models import ColumnDataSource, RangeTool
    from bokeh.layouts import column
    from bokeh.plotting import figure, show

    n = 10
    x = np.random.random(n)
    y = np.random.random(n)
    z = np.arange(n)
    source = ColumnDataSource(data=dict(x=x, y=y, z=z, xy=x+y))

    plotxy = figure(plot_width=800, plot_height=800)
    plotxy.scatter('x', 'y', source=source)

    plotz = figure(plot_width=800, plot_height=100)
    plotz.line('z', 'xy', source=source)
    range_rool = RangeTool(x_range=plotz.x_range)
    plotz.add_tools(range_rool)

    p = column([plotxy, plotz])
    show(p)


    However, the RangeTool seems incompatible with this approach since I get:



    expected an instance of type Range1d, got DataRange1d(id='13429', ...) of type DataRange1d


    on the following row: range_rool = RangeTool(x_range=plotz.x_range).
    Changing it to x_range=Range1d(z[0], z[-1]) makes everything appear correctly, but the brushing has no effect on the main figure.



    I can get the interaction I want using this instead for the secondary figure:



    plotz = figure(plot_width=800, plot_height=100, tools='xbox_select')
    plotz.scatter('t', 'xy', source=source)
    plotz.line('t', 'xy', source=source)


    The problem here is that the BoxSelectionTool is not persistent and draggable, which is the key functionality I want to have.



    Since the brushing works on the BoxSelectionTool perfectly, is this missing from the RangeTool API so this is impossible, or am I using the wrong approach here?
    (PS. adding the scatter to the secondary figure has no effect on the RangeTool)



    Is there any way to get this interaction behavior easily? Thanks.










    share|improve this question
























      0












      0








      0


      1






      Following the example for the RangeTool here: https://bokeh.pydata.org/en/latest/docs/gallery/range_tool.html, I ran into some issues. I want to have the secondary plot's range tool brush the data on a dimension not displayed by the main plot (z in this example), and have the data in the main plot brushed according to the selection on the secondary plot. So I did the following:



      import numpy as np
      from bokeh.models import ColumnDataSource, RangeTool
      from bokeh.layouts import column
      from bokeh.plotting import figure, show

      n = 10
      x = np.random.random(n)
      y = np.random.random(n)
      z = np.arange(n)
      source = ColumnDataSource(data=dict(x=x, y=y, z=z, xy=x+y))

      plotxy = figure(plot_width=800, plot_height=800)
      plotxy.scatter('x', 'y', source=source)

      plotz = figure(plot_width=800, plot_height=100)
      plotz.line('z', 'xy', source=source)
      range_rool = RangeTool(x_range=plotz.x_range)
      plotz.add_tools(range_rool)

      p = column([plotxy, plotz])
      show(p)


      However, the RangeTool seems incompatible with this approach since I get:



      expected an instance of type Range1d, got DataRange1d(id='13429', ...) of type DataRange1d


      on the following row: range_rool = RangeTool(x_range=plotz.x_range).
      Changing it to x_range=Range1d(z[0], z[-1]) makes everything appear correctly, but the brushing has no effect on the main figure.



      I can get the interaction I want using this instead for the secondary figure:



      plotz = figure(plot_width=800, plot_height=100, tools='xbox_select')
      plotz.scatter('t', 'xy', source=source)
      plotz.line('t', 'xy', source=source)


      The problem here is that the BoxSelectionTool is not persistent and draggable, which is the key functionality I want to have.



      Since the brushing works on the BoxSelectionTool perfectly, is this missing from the RangeTool API so this is impossible, or am I using the wrong approach here?
      (PS. adding the scatter to the secondary figure has no effect on the RangeTool)



      Is there any way to get this interaction behavior easily? Thanks.










      share|improve this question














      Following the example for the RangeTool here: https://bokeh.pydata.org/en/latest/docs/gallery/range_tool.html, I ran into some issues. I want to have the secondary plot's range tool brush the data on a dimension not displayed by the main plot (z in this example), and have the data in the main plot brushed according to the selection on the secondary plot. So I did the following:



      import numpy as np
      from bokeh.models import ColumnDataSource, RangeTool
      from bokeh.layouts import column
      from bokeh.plotting import figure, show

      n = 10
      x = np.random.random(n)
      y = np.random.random(n)
      z = np.arange(n)
      source = ColumnDataSource(data=dict(x=x, y=y, z=z, xy=x+y))

      plotxy = figure(plot_width=800, plot_height=800)
      plotxy.scatter('x', 'y', source=source)

      plotz = figure(plot_width=800, plot_height=100)
      plotz.line('z', 'xy', source=source)
      range_rool = RangeTool(x_range=plotz.x_range)
      plotz.add_tools(range_rool)

      p = column([plotxy, plotz])
      show(p)


      However, the RangeTool seems incompatible with this approach since I get:



      expected an instance of type Range1d, got DataRange1d(id='13429', ...) of type DataRange1d


      on the following row: range_rool = RangeTool(x_range=plotz.x_range).
      Changing it to x_range=Range1d(z[0], z[-1]) makes everything appear correctly, but the brushing has no effect on the main figure.



      I can get the interaction I want using this instead for the secondary figure:



      plotz = figure(plot_width=800, plot_height=100, tools='xbox_select')
      plotz.scatter('t', 'xy', source=source)
      plotz.line('t', 'xy', source=source)


      The problem here is that the BoxSelectionTool is not persistent and draggable, which is the key functionality I want to have.



      Since the brushing works on the BoxSelectionTool perfectly, is this missing from the RangeTool API so this is impossible, or am I using the wrong approach here?
      (PS. adding the scatter to the secondary figure has no effect on the RangeTool)



      Is there any way to get this interaction behavior easily? Thanks.







      python bokeh






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 11:42









      ZerchaZercha

      11




      11






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337182%2fbokeh-rangetool-interaction-between-figures-using-different-dimensions%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337182%2fbokeh-rangetool-interaction-between-figures-using-different-dimensions%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          Evgeni Malkin