How to replace a plot in a tab?

Hi!

I’m currently working on changing the axes when converting units in a plot. This is done by a callback on a text-input that does simple math and produces a new array.

As the elements in the new array is approximately 10^-3 times smaller than the original I need to create an additional x-axis and a new line that is linked to the new x-axis.

The question is then how do you grab a figure from a tab, delete it and insert a new plot in the same location in real-time using bokeh serve in the background? Is it done simply with list manipulations? Or can I change the figure directly by assigning it as a variable and setting that variable as a tab and then changing the figure-variable later?

With most sincere thanks,

-Robert

Hi Robert,

I'm a little unclear from your description. Do you need a new plot, or do you just need to update an existing plot with new data? If you are using the default data ranges, then if you replace the data with smaller or larger values, the axes should update automatically. Alternatively, you can explicitly set a new start/end on existing ranges or data ranges. Or are you wanting e.g., two x-axes at the same time? Maybe a drawing or some code would help clarify your use case.

You can certainly replace an entire plot of you want/need to as well (just replace the plot in whatever layout it is in with a new plot). Just trying to understand the situation better

Thanks,

Bryan

···

On Feb 15, 2016, at 10:37 AM, Robert <[email protected]> wrote:

Hi!

I'm currently working on changing the axes when converting units in a plot. This is done by a callback on a text-input that does simple math and produces a new array.

As the elements in the new array is approximately 10^-3 times smaller than the original I need to create an additional x-axis and a new line that is linked to the new x-axis.

The question is then how do you grab a figure from a tab, delete it and insert a new plot in the same location in real-time using bokeh serve in the background? Is it done simply with list manipulations? Or can I change the figure directly by assigning it as a variable and setting that variable as a tab and then changing the figure-variable later?

With most sincere thanks,
-Robert

--
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/7347d3f5-634a-4c35-8068-688e4272858a%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

I’m sorry for not being entirely clear. A revision in my code makes the problem somewhat easier. I only wish to re-name the x-axis in a plot in a callback. Each figure exists in a Panel object as a tab in a tabs object.

tab_plots =

for i in number_of_figures:

tab_plots.append(Panel(child = hplot(figure_obj, radio_group, vform(text_input_rsf, text_input_sputter, text_input_crater_depth)), title = attr_id))

tabs = Tabs(tabs = tab_plots)

session = push_session(curdoc())

session.show()

session.loop_until_closed()

And the callback exists on the text_input_sputter/crater_depth objects by an .on_change trigger. So whichever is easier of changing the current x-axis or simply updating with an additional x-axis.

I hope that clarifies things somewhat.

Sincere thanks,

Robert

tirsdag 16. februar 2016 03.37.12 UTC+1 skrev Bryan Van de ven følgende:

···

Hi Robert,

I’m a little unclear from your description. Do you need a new plot, or do you just need to update an existing plot with new data? If you are using the default data ranges, then if you replace the data with smaller or larger values, the axes should update automatically. Alternatively, you can explicitly set a new start/end on existing ranges or data ranges. Or are you wanting e.g., two x-axes at the same time? Maybe a drawing or some code would help clarify your use case.

You can certainly replace an entire plot of you want/need to as well (just replace the plot in whatever layout it is in with a new plot). Just trying to understand the situation better

Thanks,

Bryan

On Feb 15, 2016, at 10:37 AM, Robert [email protected] wrote:

Hi!

I’m currently working on changing the axes when converting units in a plot. This is done by a callback on a text-input that does simple math and produces a new array.

As the elements in the new array is approximately 10^-3 times smaller than the original I need to create an additional x-axis and a new line that is linked to the new x-axis.

The question is then how do you grab a figure from a tab, delete it and insert a new plot in the same location in real-time using bokeh serve in the background? Is it done simply with list manipulations? Or can I change the figure directly by assigning it as a variable and setting that variable as a tab and then changing the figure-variable later?

With most sincere thanks,
-Robert


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/7347d3f5-634a-4c35-8068-688e4272858a%40continuum.io.

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

Hi Robert,

I am afraird I am still not quite clear about what exactly you want to happen. When you say "re-name the x-axis in a plot" that makes me think you wnat ot change just the axis label (which you an certainly do with "plot.xaxis.lable = 'new label'" or similar in your callback). But your earlier message seemed indicate that you are changing the data? Did you mean replacing the data entirely and responding to just the new data? Or adding some new data (on smaller scale) in addition to the data already on the plot (and also adding a new, *second* axis? I can't tell if you are asking about "twin axis" type situation or not). Perhaps some images or sketches could help clarify.

Bryan

···

On Feb 16, 2016, at 8:36 AM, Robert <[email protected]> wrote:

Hi Bryan,

I'm sorry for not being entirely clear. A revision in my code makes the problem somewhat easier. I only wish to re-name the x-axis in a plot in a callback. Each figure exists in a Panel object as a tab in a tabs object.

    tab_plots =
    for i in number_of_figures:
        tab_plots.append(Panel(child = hplot(figure_obj, radio_group, vform(text_input_rsf, text_input_sputter, text_input_crater_depth)), title = attr_id))
    
    tabs = Tabs(tabs = tab_plots)
    
    session = push_session(curdoc())
    session.show()
    session.loop_until_closed()

And the callback exists on the text_input_sputter/crater_depth objects by an .on_change trigger. So whichever is easier of changing the current x-axis or simply updating with an additional x-axis.

I hope that clarifies things somewhat.

Sincere thanks,
Robert

tirsdag 16. februar 2016 03.37.12 UTC+1 skrev Bryan Van de ven følgende:
Hi Robert,

I'm a little unclear from your description. Do you need a new plot, or do you just need to update an existing plot with new data? If you are using the default data ranges, then if you replace the data with smaller or larger values, the axes should update automatically. Alternatively, you can explicitly set a new start/end on existing ranges or data ranges. Or are you wanting e.g., two x-axes at the same time? Maybe a drawing or some code would help clarify your use case.

You can certainly replace an entire plot of you want/need to as well (just replace the plot in whatever layout it is in with a new plot). Just trying to understand the situation better

Thanks,

Bryan

> On Feb 15, 2016, at 10:37 AM, Robert <[email protected]> wrote:
>
> Hi!
>
> I'm currently working on changing the axes when converting units in a plot. This is done by a callback on a text-input that does simple math and produces a new array.
>
> As the elements in the new array is approximately 10^-3 times smaller than the original I need to create an additional x-axis and a new line that is linked to the new x-axis.
>
> The question is then how do you grab a figure from a tab, delete it and insert a new plot in the same location in real-time using bokeh serve in the background? Is it done simply with list manipulations? Or can I change the figure directly by assigning it as a variable and setting that variable as a tab and then changing the figure-variable later?
>
> With most sincere thanks,
> -Robert
>
> --
> 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/7347d3f5-634a-4c35-8068-688e4272858a%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/70ebec6b-f8ad-4ebf-b200-e86c07452682%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Yeah I just wanted to change the axis label, and it worked out great! I started out thinking i needed to create an additional axis, and as it turns out I did not need to do that. Sorry for the confusion!

Robert

fredag 19. februar 2016 15.13.43 UTC+1 skrev Bryan Van de ven følgende:

···

Hi Robert,

I am afraird I am still not quite clear about what exactly you want to happen. When you say “re-name the x-axis in a plot” that makes me think you wnat ot change just the axis label (which you an certainly do with “plot.xaxis.lable = ‘new label’” or similar in your callback). But your earlier message seemed indicate that you are changing the data? Did you mean replacing the data entirely and responding to just the new data? Or adding some new data (on smaller scale) in addition to the data already on the plot (and also adding a new, second axis? I can’t tell if you are asking about “twin axis” type situation or not). Perhaps some images or sketches could help clarify.

Bryan

On Feb 16, 2016, at 8:36 AM, Robert [email protected] wrote:

Hi Bryan,

I’m sorry for not being entirely clear. A revision in my code makes the problem somewhat easier. I only wish to re-name the x-axis in a plot in a callback. Each figure exists in a Panel object as a tab in a tabs object.

tab_plots = []
for i in number_of_figures:
    tab_plots.append(Panel(child = hplot(figure_obj, radio_group, vform(text_input_rsf, text_input_sputter, text_input_crater_depth)), title = attr_id))
tabs = Tabs(tabs = tab_plots)
session = push_session(curdoc())
session.show()
session.loop_until_closed()

And the callback exists on the text_input_sputter/crater_depth objects by an .on_change trigger. So whichever is easier of changing the current x-axis or simply updating with an additional x-axis.

I hope that clarifies things somewhat.

Sincere thanks,

Robert

tirsdag 16. februar 2016 03.37.12 UTC+1 skrev Bryan Van de ven følgende:

Hi Robert,

I’m a little unclear from your description. Do you need a new plot, or do you just need to update an existing plot with new data? If you are using the default data ranges, then if you replace the data with smaller or larger values, the axes should update automatically. Alternatively, you can explicitly set a new start/end on existing ranges or data ranges. Or are you wanting e.g., two x-axes at the same time? Maybe a drawing or some code would help clarify your use case.

You can certainly replace an entire plot of you want/need to as well (just replace the plot in whatever layout it is in with a new plot). Just trying to understand the situation better

Thanks,

Bryan

On Feb 15, 2016, at 10:37 AM, Robert [email protected] wrote:

Hi!

I’m currently working on changing the axes when converting units in a plot. This is done by a callback on a text-input that does simple math and produces a new array.

As the elements in the new array is approximately 10^-3 times smaller than the original I need to create an additional x-axis and a new line that is linked to the new x-axis.

The question is then how do you grab a figure from a tab, delete it and insert a new plot in the same location in real-time using bokeh serve in the background? Is it done simply with list manipulations? Or can I change the figure directly by assigning it as a variable and setting that variable as a tab and then changing the figure-variable later?

With most sincere thanks,
-Robert


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/7347d3f5-634a-4c35-8068-688e4272858a%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/70ebec6b-f8ad-4ebf-b200-e86c07452682%40continuum.io.

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