Is support for _repr_latex planned? Or, how to output to PDF.

I would very much like to use Bokeh in my IPython Notebooks (now Jupyter), but I also need to export the notebooks to PDFs. According to the IPython devs, Bokeh needs to support the _repr_latex method to allow nbconvert to save to PDF. Is this anywhere on the development plan?

I am open to alternative suggestions. For example, the IPython developer suggested that I save the Bokeh plots to files, and then hand insert latex into the nbconvert latex output. With hundreds of plots, and several regenerations a week this is a nonstarter for me. I’ve googled and seen claims that Bokeh does not support programmatic saving of plots, so I don’t believe I can automate that workflow.

I’ve tried bokeh.mpl.to_bokeh to convert a matplotlib graphs into Bokeh, with the thinking that I could perhaps plot with matplotlib, convert the matplotlib figure to Bokeh for the live notebook, but strip the conversion out with a Python script before converting to PDF so that the matplotlib plot renders. In principle that works, but I get warnings about things like legend not being supported, and in general the output is not nearly as good as the matplotlib output. I admit to not trying extremely hard on this one.

I seem to be left with either writing two versions of the plotting code for every plot and enabling the Bokeh or matplotlib version depending on whether I’m converting to PDF, or writing a compatibility layer

Anyway, the output of Bokeh is fantastic, and I want to use it, but it is hard to use for static/printed output unless I am missing something.

Hi

Programmatic generation of static images is definitely something we would very much like to support. Unfortunately, it is also a surprisingly difficult proposition. The first observation is that browsers canvas implementation only generate raster images, and don't help with SVG or PDF. Worse, browser security models mean that getting the data out is also very problematic. You can follow this history of this topic in a few issues:

  https://github.com/bokeh/bokeh/issues/538
  https://github.com/bokeh/bokeh/issues/1589

MPL support is currently provided by a third party library, mplexporter. It is very useful in a large number of cases, but it is by no means complete, which explains errors you have seen. There is a MPL enhancement proposal to make a "serious" complete JSON serialization layer, much better than mplexorter. In principle this would work fantastically, allowing us to leverage all the MPL work for static image generation. But realistically, there are no indications that this work will materialize or even really get started any time in the near future (best guess: years, if at all). So, the current plan is to try and use the current BokehjS patched with node-canvas to generate images inside Node. But BokehJS is a large and complicated library and it is unclear that Node support is currently up to the task. Experiments and tests are ongoing. If the current plan proves unworkable, I am afraid that really only leaves the very undesirable proposition of creating and maintaining our own "duplicate" rendering code path in python that mirrors the BokehJS rendering code. This is obviously bad from an effort/maintenance viewpoint, but it's also disappointing because it means static image generation won't "just work" for other language bindings without including some python code or a python tool. However, given that we are probably going to make a move to WebGL for browser rendering, this may truly be the "best worst" possibility. But obviously it is a nontrivial undertaking that will take a nontrivial amount of time and effort.

I wish I had some better news to give you. It is my earnest hope that we will have a solution in 2015 but I can't provide any better estimates at this time.

Thanks,

Bryan

···

On Mar 3, 2015, at 5:49 PM, [email protected] wrote:

I would very much like to use Bokeh in my IPython Notebooks (now Jupyter), but I also need to export the notebooks to PDFs. According to the IPython devs, Bokeh needs to support the _repr_latex method to allow nbconvert to save to PDF. Is this anywhere on the development plan?

I am open to alternative suggestions. For example, the IPython developer suggested that I save the Bokeh plots to files, and then hand insert latex into the nbconvert latex output. With hundreds of plots, and several regenerations a week this is a nonstarter for me. I've googled and seen claims that Bokeh does not support programmatic saving of plots, so I don't believe I can automate that workflow.

I've tried bokeh.mpl.to_bokeh to convert a matplotlib graphs into Bokeh, with the thinking that I could perhaps plot with matplotlib, convert the matplotlib figure to Bokeh for the live notebook, but strip the conversion out with a Python script before converting to PDF so that the matplotlib plot renders. In principle that works, but I get warnings about things like legend not being supported, and in general the output is not nearly as good as the matplotlib output. I admit to not trying extremely hard on this one.

I seem to be left with either writing two versions of the plotting code for every plot and enabling the Bokeh or matplotlib version depending on whether I'm converting to PDF, or writing a compatibility layer

Anyway, the output of Bokeh is fantastic, and I want to use it, but it is hard to use for static/printed output unless I am missing something.

--
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/bd66d217-5f04-4c58-a70d-86d312f26fa6%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks Bryan,

That all makes sense, thanks for taking the time to explain in detail.

···

On Wednesday, March 4, 2015 at 6:36:04 PM UTC-8, Bryan Van de ven wrote:

Hi

Programmatic generation of static images is definitely something we would very much like to support. Unfortunately, it is also a surprisingly difficult proposition. The first observation is that browsers canvas implementation only generate raster images, and don’t help with SVG or PDF. Worse, browser security models mean that getting the data out is also very problematic. You can follow this history of this topic in a few issues:

    [https://github.com/bokeh/bokeh/issues/538](https://github.com/bokeh/bokeh/issues/538)

    [https://github.com/bokeh/bokeh/issues/1589](https://github.com/bokeh/bokeh/issues/1589)

MPL support is currently provided by a third party library, mplexporter. It is very useful in a large number of cases, but it is by no means complete, which explains errors you have seen. There is a MPL enhancement proposal to make a “serious” complete JSON serialization layer, much better than mplexorter. In principle this would work fantastically, allowing us to leverage all the MPL work for static image generation. But realistically, there are no indications that this work will materialize or even really get started any time in the near future (best guess: years, if at all). So, the current plan is to try and use the current BokehjS patched with node-canvas to generate images inside Node. But BokehJS is a large and complicated library and it is unclear that Node support is currently up to the task. Experiments and tests are ongoing. If the current plan proves unworkable, I am afraid that really only leaves the very undesirable proposition of creating and maintaining our own “duplicate” rendering code path in python that mirrors the BokehJS rendering code. This is obviously bad from an effort/maintenance viewpoint, but it’s also disappointing because it means static image generation won’t “just work” for other language bindings without including some python code or a python tool. However, given that we are probably going to make a move to WebGL for browser rendering, this may truly be the “best worst” possibility. But obviously it is a nontrivial undertaking that will take a nontrivial amount of time and effort.

I wish I had some better news to give you. It is my earnest hope that we will have a solution in 2015 but I can’t provide any better estimates at this time.

Thanks,

Bryan

On Mar 3, 2015, at 5:49 PM, [email protected] wrote:

I would very much like to use Bokeh in my IPython Notebooks (now Jupyter), but I also need to export the notebooks to PDFs. According to the IPython devs, Bokeh needs to support the _repr_latex method to allow nbconvert to save to PDF. Is this anywhere on the development plan?

I am open to alternative suggestions. For example, the IPython developer suggested that I save the Bokeh plots to files, and then hand insert latex into the nbconvert latex output. With hundreds of plots, and several regenerations a week this is a nonstarter for me. I’ve googled and seen claims that Bokeh does not support programmatic saving of plots, so I don’t believe I can automate that workflow.

I’ve tried bokeh.mpl.to_bokeh to convert a matplotlib graphs into Bokeh, with the thinking that I could perhaps plot with matplotlib, convert the matplotlib figure to Bokeh for the live notebook, but strip the conversion out with a Python script before converting to PDF so that the matplotlib plot renders. In principle that works, but I get warnings about things like legend not being supported, and in general the output is not nearly as good as the matplotlib output. I admit to not trying extremely hard on this one.

I seem to be left with either writing two versions of the plotting code for every plot and enabling the Bokeh or matplotlib version depending on whether I’m converting to PDF, or writing a compatibility layer

Anyway, the output of Bokeh is fantastic, and I want to use it, but it is hard to use for static/printed output unless I am missing something.


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/bd66d217-5f04-4c58-a70d-86d312f26fa6%40continuum.io.

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

I’m wondering if there has been any update to this? I’m at a crossroads with a big project but vector output is mandatory.

Thanks,

Colin

···

On Thursday, March 5, 2015 at 4:30:05 PM UTC-8, [email protected] wrote:

Thanks Bryan,

That all makes sense, thanks for taking the time to explain in detail.

On Wednesday, March 4, 2015 at 6:36:04 PM UTC-8, Bryan Van de ven wrote:

Hi

Programmatic generation of static images is definitely something we would very much like to support. Unfortunately, it is also a surprisingly difficult proposition. The first observation is that browsers canvas implementation only generate raster images, and don’t help with SVG or PDF. Worse, browser security models mean that getting the data out is also very problematic. You can follow this history of this topic in a few issues:

    [https://github.com/bokeh/bokeh/issues/538](https://github.com/bokeh/bokeh/issues/538)

    [https://github.com/bokeh/bokeh/issues/1589](https://github.com/bokeh/bokeh/issues/1589)

MPL support is currently provided by a third party library, mplexporter. It is very useful in a large number of cases, but it is by no means complete, which explains errors you have seen. There is a MPL enhancement proposal to make a “serious” complete JSON serialization layer, much better than mplexorter. In principle this would work fantastically, allowing us to leverage all the MPL work for static image generation. But realistically, there are no indications that this work will materialize or even really get started any time in the near future (best guess: years, if at all). So, the current plan is to try and use the current BokehjS patched with node-canvas to generate images inside Node. But BokehJS is a large and complicated library and it is unclear that Node support is currently up to the task. Experiments and tests are ongoing. If the current plan proves unworkable, I am afraid that really only leaves the very undesirable proposition of creating and maintaining our own “duplicate” rendering code path in python that mirrors the BokehJS rendering code. This is obviously bad from an effort/maintenance viewpoint, but it’s also disappointing because it means static image generation won’t “just work” for other language bindings without including some python code or a python tool. However, given that we are probably going to make a move to WebGL for browser rendering, this may truly be the “best worst” possibility. But obviously it is a nontrivial undertaking that will take a nontrivial amount of time and effort.

I wish I had some better news to give you. It is my earnest hope that we will have a solution in 2015 but I can’t provide any better estimates at this time.

Thanks,

Bryan

On Mar 3, 2015, at 5:49 PM, [email protected] wrote:

I would very much like to use Bokeh in my IPython Notebooks (now Jupyter), but I also need to export the notebooks to PDFs. According to the IPython devs, Bokeh needs to support the _repr_latex method to allow nbconvert to save to PDF. Is this anywhere on the development plan?

I am open to alternative suggestions. For example, the IPython developer suggested that I save the Bokeh plots to files, and then hand insert latex into the nbconvert latex output. With hundreds of plots, and several regenerations a week this is a nonstarter for me. I’ve googled and seen claims that Bokeh does not support programmatic saving of plots, so I don’t believe I can automate that workflow.

I’ve tried bokeh.mpl.to_bokeh to convert a matplotlib graphs into Bokeh, with the thinking that I could perhaps plot with matplotlib, convert the matplotlib figure to Bokeh for the live notebook, but strip the conversion out with a Python script before converting to PDF so that the matplotlib plot renders. In principle that works, but I get warnings about things like legend not being supported, and in general the output is not nearly as good as the matplotlib output. I admit to not trying extremely hard on this one.

I seem to be left with either writing two versions of the plotting code for every plot and enabling the Bokeh or matplotlib version depending on whether I’m converting to PDF, or writing a compatibility layer

Anyway, the output of Bokeh is fantastic, and I want to use it, but it is hard to use for static/printed output unless I am missing something.


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/bd66d217-5f04-4c58-a70d-86d312f26fa6%40continuum.io.

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

Hi Colin,

This is as always, something we would very much like to have, but at the same time something that is unfortunately technically difficult. There is currently an in-flight PR with the goal of getting BokehJS runnable in Node, which would then use canvas-cairo to emit static images directly from standard Bokeh JSON and the existing BokehJS rendering canvas rendering codebase. BokehJS and Node have both seen improvements in the last two years that make this approach more promising than it was in the past. However, I would say any final results from this are at least a few months away. We would also be interested in leveraging MPL for a rendering backend, but this depends on the implementation of MEP25 by the Matplotlib team, and we have no control over that schedule. The last option would be to create another custom rendering backend from scratch that renders static images from Bokeh JSON. This is something we would conceivably consider if all else fails, but it's obviously a large investment of time and effort and there are other priorities and limited resources (certainly we'd help anyone that wanted to work on this before we could).

I wish I had better news to give you and if Bokeh is not suitable for your needs now, I hope it becomes so in the future.

Regards,

Bryan

···

On Jan 2, 2016, at 1:14 PM, [email protected] wrote:

I'm wondering if there has been any update to this? I'm at a crossroads with a big project but vector output is mandatory.

Thanks,

Colin

On Thursday, March 5, 2015 at 4:30:05 PM UTC-8, [email protected] wrote:
Thanks Bryan,

That all makes sense, thanks for taking the time to explain in detail.

On Wednesday, March 4, 2015 at 6:36:04 PM UTC-8, Bryan Van de ven wrote:
Hi

Programmatic generation of static images is definitely something we would very much like to support. Unfortunately, it is also a surprisingly difficult proposition. The first observation is that browsers canvas implementation only generate raster images, and don't help with SVG or PDF. Worse, browser security models mean that getting the data out is also very problematic. You can follow this history of this topic in a few issues:

        https://github.com/bokeh/bokeh/issues/538
        https://github.com/bokeh/bokeh/issues/1589

MPL support is currently provided by a third party library, mplexporter. It is very useful in a large number of cases, but it is by no means complete, which explains errors you have seen. There is a MPL enhancement proposal to make a "serious" complete JSON serialization layer, much better than mplexorter. In principle this would work fantastically, allowing us to leverage all the MPL work for static image generation. But realistically, there are no indications that this work will materialize or even really get started any time in the near future (best guess: years, if at all). So, the current plan is to try and use the current BokehjS patched with node-canvas to generate images inside Node. But BokehJS is a large and complicated library and it is unclear that Node support is currently up to the task. Experiments and tests are ongoing. If the current plan proves unworkable, I am afraid that really only leaves the very undesirable proposition of creating and maintaining our own "duplicate" rendering code path in python that mirrors the BokehJS rendering code. This is obviously bad from an effort/maintenance viewpoint, but it's also disappointing because it means static image generation won't "just work" for other language bindings without including some python code or a python tool. However, given that we are probably going to make a move to WebGL for browser rendering, this may truly be the "best worst" possibility. But obviously it is a nontrivial undertaking that will take a nontrivial amount of time and effort.

I wish I had some better news to give you. It is my earnest hope that we will have a solution in 2015 but I can't provide any better estimates at this time.

Thanks,

Bryan

> On Mar 3, 2015, at 5:49 PM, [email protected] wrote:
>
> I would very much like to use Bokeh in my IPython Notebooks (now Jupyter), but I also need to export the notebooks to PDFs. According to the IPython devs, Bokeh needs to support the _repr_latex method to allow nbconvert to save to PDF. Is this anywhere on the development plan?
>
> I am open to alternative suggestions. For example, the IPython developer suggested that I save the Bokeh plots to files, and then hand insert latex into the nbconvert latex output. With hundreds of plots, and several regenerations a week this is a nonstarter for me. I've googled and seen claims that Bokeh does not support programmatic saving of plots, so I don't believe I can automate that workflow.
>
> I've tried bokeh.mpl.to_bokeh to convert a matplotlib graphs into Bokeh, with the thinking that I could perhaps plot with matplotlib, convert the matplotlib figure to Bokeh for the live notebook, but strip the conversion out with a Python script before converting to PDF so that the matplotlib plot renders. In principle that works, but I get warnings about things like legend not being supported, and in general the output is not nearly as good as the matplotlib output. I admit to not trying extremely hard on this one.
>
> I seem to be left with either writing two versions of the plotting code for every plot and enabling the Bokeh or matplotlib version depending on whether I'm converting to PDF, or writing a compatibility layer
>
> Anyway, the output of Bokeh is fantastic, and I want to use it, but it is hard to use for static/printed output unless I am missing something.
>
> --
> 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/bd66d217-5f04-4c58-a70d-86d312f26fa6%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/0057778a-5efc-4c3c-a77d-bfbd00934502%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.