Browser plotting backend cannot be changed on-the-fly

I have a question regarding the generation of svg plots.

What I want was basically use “canvas” as the plotting tool but when save using save tool, generates SVG plot.

The reason that I want this, is because when using svg as backend, not only the render is very slow, but also when I use any tool on the interactive plot, the plot drifts (seems like a bug).

Now my temporary solution is to add a checkbox: when checked, the plot output_backend will switch to “svg” and when unchecked, it will switch back to “canvas”.

What I have noticed is that this does not work at all. It seems like once added to curdoc, changing output_backend on the server will bring no effect to the interactive plot on the client (browser).

After changing the output_backend after adding the plot to curdoc, clicking the “save” button brings no effect. But mysteriously the “save” button works again after switching back the output_backend to “canvas”, generating a “png” file for download.

Interestingly, after switching the output_backend to “svg”, the export_svg() function works fine on the server side, storing an SVG file on the server hard drive, as expected. This suggests that the plot output_backend is actually switched to “svg” on the server but not on the browser.

Is there a way to trigger output_backend switch on the browser?

I think the expected behavior should be that once output_backend changes, it changes on both server and client. Right now it’s behavior is really weird.

Would appreciate any help on this! Thanks!

Hongyi

···

On Wednesday, December 19, 2018 at 3:57:55 PM UTC-5, Hongyi Xin wrote:

I have a question regarding the generation of svg plots.

What I want was basically use “canvas” as the plotting tool but when save using save tool, generates SVG plot.

The reason that I want this, is because when using svg as backend, not only the render is very slow, but also when I use any tool on the interactive plot, the plot drifts (seems like a bug).

Now my temporary solution is to add a checkbox: when checked, the plot output_backend will switch to “svg” and when unchecked, it will switch back to “canvas”.

What I have noticed is that this does not work at all. It seems like once added to curdoc, changing output_backend on the server will bring no effect to the interactive plot on the client (browser).

After changing the output_backend after adding the plot to curdoc, clicking the “save” button brings no effect. But mysteriously the “save” button works again after switching back the output_backend to “canvas”, generating a “png” file for download.

Interestingly, after switching the output_backend to “svg”, the export_svg() function works fine on the server side, storing an SVG file on the server hard drive, as expected. This suggests that the plot output_backend is actually switched to “svg” on the server but not on the browser.

Is there a way to trigger output_backend switch on the browser?

Hi,

I would not expect dynamically changing the output backend dynamically to work. It's possibly something we could consider looking into, but given the current available resource levels and the relative rarity of this use case, it's probably not something that could be prioritized anytime soon.

Thanks,

Bryan

···

On Dec 19, 2018, at 13:00, Hongyi Xin <[email protected]> wrote:

I think the expected behavior should be that once output_backend changes, it changes on both server and client. Right now it's behavior is really weird.

Would appreciate any help on this! Thanks!

Hongyi

On Wednesday, December 19, 2018 at 3:57:55 PM UTC-5, Hongyi Xin wrote:
I have a question regarding the generation of svg plots.

What I want was basically use "canvas" as the plotting tool but when save using save tool, generates SVG plot.

The reason that I want this, is because when using svg as backend, not only the render is very slow, but also when I use any tool on the interactive plot, the plot drifts (seems like a bug).

Now my temporary solution is to add a checkbox: when checked, the plot output_backend will switch to "svg" and when unchecked, it will switch back to "canvas".

What I have noticed is that this does not work at all. It seems like once added to curdoc, changing output_backend on the server will bring no effect to the interactive plot on the client (browser).

After changing the output_backend after adding the plot to curdoc, clicking the "save" button brings no effect. But mysteriously the "save" button works again after switching back the output_backend to "canvas", generating a "png" file for download.

Interestingly, after switching the output_backend to "svg", the export_svg() function works fine on the server side, storing an SVG file on the server hard drive, as expected. This suggests that the plot output_backend is actually switched to "svg" on the server but not on the browser.

Is there a way to trigger output_backend switch on the browser?

--
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/35dbfffb-2dca-43f1-8166-30f7e30a71b8%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

I have a question regarding the generation of svg plots.

What I want was basically use “canvas” as the plotting tool but when save using save tool, generates SVG plot.

The reason that I want this, is because when using svg as backend, not only the render is very slow, but also when I use any tool on the interactive plot, the plot drifts (seems like a bug).

Now my temporary solution is to add a checkbox: when checked, the plot output_backend will switch to “svg” and when unchecked, it will switch back to “canvas”.

What I have noticed is that this does not work at all. It seems like once added to curdoc, changing output_backend on the server will bring no effect to the interactive plot on the client (browser).

After changing the output_backend after adding the plot to curdoc, clicking the “save” button brings no effect. But mysteriously the “save” button works again after switching back the output_backend to “canvas”, generating a “png” file for download.

Interestingly, after switching the output_backend to “svg”, the export_svg() function works fine on the server side, storing an SVG file on the server hard drive, as expected. This suggests that the plot output_backend is actually switched to “svg” on the server but not on the browser.

Is there a way to trigger output_backend switch on the browser?

this looks like a bug (one of many of this kind, where bokehjs either doesn’t listen to properties’ change events or doesn’t do enough acting on such events). What you can do is to replace entire plot with a different backend set. Note that changing a backend requires complete reinitialization of a plot, so this approach isn’t much more inefficient.

Mateusz

···

On Wed, Dec 19, 2018 at 9:57 PM Hongyi Xin [email protected] wrote:

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/95ad2629-35e8-4ab9-a396-1e06c7c3a0e6%40continuum.io.

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

Thanks Mateusz and Bryan for the very timely reply. Appreciated!

I would give reinitialization a try.

I think exporting vector graphics is actually a very important feature, at least for academia. Lots of work in research goes into generating pretty plots (which bokeh is of course one of the best tools out there). When publishing with a renounced venue, one of the first things the editor asks is to provide plots in SVG formats like PDFs.

One of the major feedback that I received when I showed my webtool built with bokeh to my colleagues is how to download the plot in SVG format.

Maybe dynamically changing output_backend on the client side is a rare use case but being able to save and download SVG plots from browser is definitely not a rare need.

I feel like Bokeh is almost there since there is already SVG support on the server side as it seems like I actually can switch the output_backend dynamically and export the SVG plot on the server. The only thing missing in my opinion is to transfer that file to the client and initiate a download request.

If possible, I was thinking maybe I can invest some time looking into this. Right now it feels like a small imperfection on an otherwise perfect jewel.

···

On Wednesday, December 19, 2018 at 4:09:48 PM UTC-5, mateusz.paprocki wrote:

Hi,

On Wed, Dec 19, 2018 at 9:57 PM Hongyi Xin [email protected] wrote:

I have a question regarding the generation of svg plots.

What I want was basically use “canvas” as the plotting tool but when save using save tool, generates SVG plot.

The reason that I want this, is because when using svg as backend, not only the render is very slow, but also when I use any tool on the interactive plot, the plot drifts (seems like a bug).

Now my temporary solution is to add a checkbox: when checked, the plot output_backend will switch to “svg” and when unchecked, it will switch back to “canvas”.

What I have noticed is that this does not work at all. It seems like once added to curdoc, changing output_backend on the server will bring no effect to the interactive plot on the client (browser).

After changing the output_backend after adding the plot to curdoc, clicking the “save” button brings no effect. But mysteriously the “save” button works again after switching back the output_backend to “canvas”, generating a “png” file for download.

Interestingly, after switching the output_backend to “svg”, the export_svg() function works fine on the server side, storing an SVG file on the server hard drive, as expected. This suggests that the plot output_backend is actually switched to “svg” on the server but not on the browser.

Is there a way to trigger output_backend switch on the browser?

this looks like a bug (one of many of this kind, where bokehjs either doesn’t listen to properties’ change events or doesn’t do enough acting on such events). What you can do is to replace entire plot with a different backend set. Note that changing a backend requires complete reinitialization of a plot, so this approach isn’t much more inefficient.

Mateusz

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/95ad2629-35e8-4ab9-a396-1e06c7c3a0e6%40continuum.io.

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

Hi,

If you are able to devote some effort to looking into improving SVG export, we are happy to offer help and guidance, and I am sure it would be appreciated by other users (especially academic users as you say).

Thanks,

Bryan

···

On Dec 19, 2018, at 13:59, Hongyi Xin <[email protected]> wrote:

Thanks Mateusz and Bryan for the very timely reply. Appreciated!

I would give reinitialization a try.

I think exporting vector graphics is actually a very important feature, at least for academia. Lots of work in research goes into generating pretty plots (which bokeh is of course one of the best tools out there). When publishing with a renounced venue, one of the first things the editor asks is to provide plots in SVG formats like PDFs.

One of the major feedback that I received when I showed my webtool built with bokeh to my colleagues is how to download the plot in SVG format.

Maybe dynamically changing output_backend on the client side is a rare use case but being able to save and download SVG plots from browser is definitely not a rare need.

I feel like Bokeh is almost there since there is already SVG support on the server side as it seems like I actually can switch the output_backend dynamically and export the SVG plot on the server. The only thing missing in my opinion is to transfer that file to the client and initiate a download request.

If possible, I was thinking maybe I can invest some time looking into this. Right now it feels like a small imperfection on an otherwise perfect jewel.

On Wednesday, December 19, 2018 at 4:09:48 PM UTC-5, mateusz.paprocki wrote:
Hi,

On Wed, Dec 19, 2018 at 9:57 PM Hongyi Xin <[email protected]> wrote:
I have a question regarding the generation of svg plots.

What I want was basically use "canvas" as the plotting tool but when save using save tool, generates SVG plot.

The reason that I want this, is because when using svg as backend, not only the render is very slow, but also when I use any tool on the interactive plot, the plot drifts (seems like a bug).

Now my temporary solution is to add a checkbox: when checked, the plot output_backend will switch to "svg" and when unchecked, it will switch back to "canvas".

What I have noticed is that this does not work at all. It seems like once added to curdoc, changing output_backend on the server will bring no effect to the interactive plot on the client (browser).

After changing the output_backend after adding the plot to curdoc, clicking the "save" button brings no effect. But mysteriously the "save" button works again after switching back the output_backend to "canvas", generating a "png" file for download.

Interestingly, after switching the output_backend to "svg", the export_svg() function works fine on the server side, storing an SVG file on the server hard drive, as expected. This suggests that the plot output_backend is actually switched to "svg" on the server but not on the browser.

Is there a way to trigger output_backend switch on the browser?

this looks like a bug (one of many of this kind, where bokehjs either doesn't listen to properties' change events or doesn't do enough acting on such events). What you can do is to replace entire plot with a different backend set. Note that changing a backend requires complete reinitialization of a plot, so this approach isn't much more inefficient.

Mateusz

--
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/95ad2629-35e8-4ab9-a396-1e06c7c3a0e6%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/3122b2c2-f2fe-4cf8-8477-5593eb027fc0%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.