How to export Bokeh view to Matplotlib? - python

I have a Flask web app that uses Bokeh to deliver interactive charts. My end goal is to export whatever the current Bokeh view is to Matplotlib (so that I can create a printable pdf file after that). This would include how the current axes look like after the user zooms and pans. Is there a way to export that data so that I can create those Matplotlib charts behind the scenes? (Printing the page directly or printing to pdf results in low-quality and blurred charts.)
Thanks!

No, currently there is no way to export bokeh to matplotlib. Actually you can do it otherway. You can create matplotlib plot, save, and after that you can export matplotlib to bokeh. I think this is the best option. Eventually you can export bokeh plot as png but it still would not solve problem with quality

Related

Include Python / Bokeh plot in PowerPoint presentation preserving data pop-ups

If an EXCEL chart is pasted into a PowerPoint presentation as an EXCEL object, it is possible to hover the mouse over the line and see it's value. My boss likes this feature. I don't like having to do charts in EXCEL.
It is possible to get the same effect with bokeh or plotly, but as far as I am aware, that either relies on a stand-alone html file or a server instance.
Is it possible to paste a bokeh chart into a PowerPoint presentation preserving the feature that when you hover your mouse over a point, the value (and some other information) pops up?
Or is there another python solution that would allow this feature in PowerPoint (ppt is essential) while also allowing plots to be generated via code?
An available option is to create powerpoints with Plotly: https://towardsdatascience.com/embed-interactive-plots-in-your-slides-with-plotly-fde92a5865a and https://evidencen.com/how-to-embed-plotly-graphs-in-powerpoint/
Also it seems this question has been asked before and you can hyperlink the HTML source in the .pptx file: Output of Plotly in PowerPoint
yes. it's a hover tool. here is an example

Doubts about adding matplotlib graphs to a webpage

So, I'm learning how to use matplotlib and stumbled into MPLD3 as the most used way to get these plots in a webpage. However, MPLD3 doesn't support tick formatting and that's something critical for the project I'm in right now. I'd like to know if there is another way to add a matplotlib graph to a webpage while keeping the tick formatting and also having tooltips to display data on hover.
Thanks!
For a web application I would consider bokeh. You can output html with interactive charts or run another backend server. If you go to the ipython notebook tutorial section 10 has demos for embedding.
Alternatively you can just save images from matplotlib and use them as static assets in your page.

Matplot lib image properties in web (Django)

I'd like to output the image to the web created in matplotlib having the very same functionality like it has on desktop when you run the image.show(), for example scaling, moving along the plot more thoroughly.
I've checked out #stack and got old post only offering static images or gif or matplotlib.animate()
I aslo had a look at matplotlib widgets, but those are for desktop GUI only as far as I can see.
Please share some experience or ideas regarding how can I achieve it.
Thanks
Matplotlib is a server side library so you cannot do anything on the client side like that.
The closest you can come is to either use mpld3 (mpld3 works by converting a matplotlib graph into the html/js that a d3 js graph would need to render) or a different client side library that plots points.
The easiest way of serving pure matplotlib to the web is using a jupyter notebook.
Other than that, you may want to look at specific libraries like Plotly or bokeh.

Is it possible to use matplotlib's interactive plotting features within Django?

I know Matplotlib can be used in Django, based on the documentation. However, I'd like to be able to create interactive graphs within a webpage (i.e clickable points). In order to display a graph created in a Python script, Django spits out a png image. I haven't tested it out myself, but the fact that Django only spits out a png is worrisome. Is what I'm trying to do possible?
http://scipy-cookbook.readthedocs.io/items/Matplotlib_Django.html
http://scipy-cookbook.readthedocs.io/items/Matplotlib_Interactive_Plotting.html

Obtain the current value when parsing an html file with bokeh sliders

I am using bokeh to plot my math functions created with python/numpy.
I would like to use sliders as shown in
http://docs.bokeh.org/en/latest/docs/server_gallery/sliders_server.html
Once I create the html file with the plot, I would like to select different values on the sliders which modify the plot and then read back the chosen values in into python to use it for other manipulations.
What is the best way to read the chosen value on the slider from the html file back into python ?
I saw pyquery could be useful, but I cannot really figure that out.
Any suggestions would be appreciated based on above scenario.
There are two slider examples in the bokeh repo, where the slider is connected back to python via the bokeh server.
Sliders App
Taylor server
If this isn't what you were after, can you elaborate a little more?
A static HTML file and the state of the slider is inside a web browser and never reflected back to the HTML file. What you should be doing is to use bokeh-server - answered via bokeh-google group

Categories

Resources