The bokeh serve feature allows periodic callbacks that execute python code in the browser window at specified intervals. Do any of the other python visualization libraries like matplotlib or plotly or geoviews support this type of interactive updating in the browser window? By browser, I mean in a browser as a web page ready for deploying over the network, not Jupyter notebooks during development.
Voila allows the interactive updating in a more general sense in that it isn't tied to any one python visualization library. You use ipywidgets to connect interactivity, output, and underlying Python code. For example, callbacks are discussed here. You can see a number of examples in the Voila gallery. I have some simpler examples here.
Someone had similar questions about bqplot here.
Related
If I am given a dataset (say excel file), I would like to deploy a webserver on which I upload this excel file, it runs python/numpy code and displays some figure.
I could also have some checkboxes on the website that would change the parameters in the code.
What tools would you recommend for doing that? What would be the easiest way?
For now I have the python code on jupyter notebook and use:
from ipywidgets.embed import embed_minimal_html
embed_minimal_html('export.html', views=[fig])
to see my figure (fig) locally, by running: python -m http.server 8080
I would like this to be deployed and choosing the file to upload.
In my opinion Django may be the best option for you. It requires Python knowledge and basic HTML/CSS -for basic usage-, that is why I thought it is the best option.
You can develope python scripts and user can able to modify the input for that python script and easily create an dashboard with graphics/calculations.
You may want to check Vitor's website:
Simple is the Best by Vitor Freitas
Use a Github repo to host your code, and then share it via MyBinder.org. An example, that is simpler than yours, but like what you describe in some ways is here. When you get there click the launch badge and a temporary session will spin up. In the notebook that comes up, you can do Run All Cells under the Run menu. The session dies after 10 minutes of inactivity. You can download useful information. See more about the MyBinder project here. I am taking advantage of the drag and drop for file upload that comes with JupyterLab here but there are file upload widgets (see below).
That example one doesn't have fancy widgets like toggles to make the choices but you can add them. For example, see the appmode demo. (Click launch binder button on the page.) You'll see you can have the widgets in the notebook or in the 'appmode'. You can make the interactions with the widgets fancier, too. Some examples featured in the Voila gallery will give you more of an idea of what is possible with the widgets and communicating to your underlying python. All those are on Github and served via temporary sessions from MyBinder.org. Keep in mind those apps can run in the notebook if you want that. The widgets work there in the notebook versions as well, too. And you can directly link to the notebook mode if you prefer, as shown under the heading 'Direct links to start out in notebook mode' here.
I currently run a personal website using Wordpress (but hosted on siteground) that is a set of engineering study guides. I would like to move towards making these study guides interactive (i.e. refreshing graphics based on sliders, doing basic calculations to indicate if a design works or not, so I need numpy). A friend recommended that I utilize Jupyter notebooks for this purpose, as you can both render LaTeX (which I'm currently using Mathjax with Wordpress to do), as well as have the types of interactive graphics I want using either Bokeh or Plotly.
While I've seen tutorials for sharing notebooks on specific servers, what I'm after is being able for others to run my notebook in their browser (read-only), where the notebook is privately hosted.
I'm still not sure if Jupyter is the correct avenue to accomplish what I want, so I'm open to other suggestions (someone also recommended using Julia, but I've seen fewer examples of this).
I agree with your friend that Jupyter Notebooks is an excellent approach. And while it's by no means the only method to accomplish what you're after, I'm hard-pressed to come up with an immediate alternative that doesn't require significant work to set up.
I can think of three primary methods of using Jupyter Notebooks which suit your needs:
1. Azure Notebooks
Microsoft has a new service called Azure Notebooks, which is (currently) totally free.
Azure Notebooks boasts the complete functionality of Jupyter Notebooks, and in addition to Python, users can also program cells in R and F#. As for typical usage of the service, here's a snippet from their FAQ:
Jupyter (formerly IPython), is a multi-lingual REPL on steroids. This is a free service that provides Jupyter notebooks along with supporting packages for R, Python and F# as a service. This means you can just login and get going since no installation/setup is necessary. Typical usage includes schools/instruction, giving webinars, learning languages, sharing ideas, etc. The service is provided by the Python team # Microsoft, which is part of the Data Group.
2. nbviewer
The top banner of the main Jupyter site contains a link link to an application called nbviewer.
Evidently, you can create your markdown / Jupyter syntax as a discrete page somewhere else, feed the URL to your page into nbviewer, and it'll render it for you right there in the results. If I were going to use this, I would either;
Create a discrete WordPress page for my Jupyter syntax, then feed that into nbviewer; or, more likely
Use GitHub to host my Jupyter Notebook pages (mainly for posterity and version control, over the Gist option), and use the raw text link as the source to feed into nbviewer.
3. Hosting Your Own Solution
If you're technically savy enough, I'd recommend this approach over nbviewer.
When you launch Jupyter Notebooks on your own machine, you access it through your browser using the default URL of http://localhost:8888. That means there must exist some mechanism to expose that port to external users, and allow them to have access to your Notebook, using the exact same interface. Two methods of doing so:
Using Jupyter Notebooks public server
Remotely accessing your normal Jupyter Notebook
Hope that helps! I'm curious to know if any of these options works out for you.
The Iodide Project (and subsequently, Pyodide) are two projects that aim to allow this. They're still in development, but might be worth looking into.
You can try to use Mercury framework. It allows you to transform notebooks into web applications (with interactive widgets). You need to add YAML header to the beginning of the notebook. Based on YAML the widgets will be generated. Your users can change widgets values and click Run button to execute the notebook with new inputs. You can decide whether to show or hide code for your users. You can serve multiple notebooks with Mercury on single server. It is based on Django so can be easily deployed on any server/cloud.
The example notebook:
The generated application for the above notebook:
The screenshot of app/notebooks gallery in the Mercury:
Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done.
Any hints links examples welcome.
If all you need are static plots, then it should be straightforward to draw and export to an SVG file, then display the SVG in a webpage (or export to image, as svg rendering is not reliable in all browsers). If you need interactivity, then you're going to need a different solution and probably pyqtgraph is not the tool for this job. VisPy does have some early browser support but this has only been demonstrated with ipython notebook.
Here is what I have sort of put together by pulling several threads online:
Ruby On Rails seems to be more popular than python at this moment.
If you go python, Flask and Django are good templates.
bokeh seems to be a good way of plotting to a browser.
AFAIK, there is no way to take an existing PyQt or pyqtgraph application and have it run on the web.
I am not sure how Twisted (Tornado, Node.js and Friends) fits in to the web SaaS, but I see it referred to occasionally since it is asynchronous event-driven.
People often suggest using Rest, but that seems slow to me. Not sure why...
I am running ipython remotely on a remote server. I access it using serveraddress:8888/ etc to write code for my notebooks.
When I use matplotlib of course the plots are inline. Is there any way to remotely send data so that plot window opens up? I want the whole interactive environment on matplotlib on my local machine and all the number crunching on the server machine? This is something very basic....but somehow after rumaging through google for quite a while i can't figure it out.
The upcoming release (1.4.0, should be out by end of August 2014, release candidates are available) will ship with the nbagg backend which provides interactive figures with out needing to go to native clients or resorting to using d3. All you need to do in your note book is:
import matplotlib
matplotlib.use('nbagg')
from matplotlib import pyplot as plt
And then to plot
plt.plot(range(3))
plt.show()
If you want to try this now either build from source or look at one of the release candidates.
There are two major difference between using nbagg and mpld3/bokeh.
First, you don't have interface across library interfaces (or learn js!). My understanding is that both of them create a figure, scrap it (which isn't perfect because mpl was not designed with making this easy in mind). With nbagg mouse and keyboard call backs should work with no translation, I don't think they can currently be exported to d3.
The second is that with nbagg all the rendering happens on the server, with the d3-based libraries all of the data must be naively shipped to the browser (bokeh is working on making this smarter and only shipping you data you can see at a useful resolution). With nbagg the only thing that comes across the network is png deltas.
There are a few possibilities
If your remote machine is somehow unixish, you may use the X Windows (then your session is on the remote machine and display on the local machine)
mpld3
bokeh and iPython notebook
nbagg backend of matplotlib.ยจ
Alternative #1 requires you to have an X server on your machine and a connection between the two machines (possibly tunneled through ssh, etc.) So, this is OS dependent, and the performance depends on the connection between the two machines.
Alternatives #2 and #3 are very new but promising. They have quite different approaches, mpl3d enables the use of standard matplotlib plotting commands, but with large datasets bokeh may be more useful.
Alternative #4 is probably the ultimate solution (see tcaswell's comments), but not yet available without using a development version of matplotlib (i.e. there may be some installation challenges). On the other hand, if you can hold your breath for a week, 1.4.0 will be out.
You want to get the regular (zoomable) plot window, right? I think you can not do it in the same kernel as, unfortunately, you can't switch from inline to qt and such because the backend has already been chosen: your calls to matplotlib.use() are always before pylab.
I am writing a Python application to be run client-side within the browser. The Skulpt project looks great for this, and I am pretty excited to begin working with it.
The one issue I can foresee, however, is that I will need graphical output using Matplotlib. Does Skulpt support Matplotlib? If not, what other options do I have?