I've been working with data visualization using Python. To do such think, I've been using Matplotlib to get the visualizations. However, now I have some demand to provide more interactive visualization, besides a complete GUI.
I'm wondering how could I do such thing without losing all work done so far in Python, i.e., if there is some tool for Python to do such thing or if I have to go to D3 or something like it.
Here there is an example of what I have to achieve. I'm not building an web app, I just need to provide a good GUI and data interaction.
Thank you in advance.
As well as targeting a web app using frameworks as suggested by mwaskom, you could try data visualization / plotting libraries that offer more interactivity than matplotlib, such as
PyQtGraph
Pyqwt
Glumpy
Vispy (new project)
Galry
I've used PyQtGraph myself in several small projects.
You could check out the mpld3 project, which aims to provide a translation between matplotlib graphics and d3. It's pretty new and rapidly developing, but it's worth at least keeping an eye on.
For a different approach, there's the vincent library, which has its own API but similarly produces d3 (by way of Vega) for making graphics that target the web in Python.
Related
Im starting a new project for personal porpuse!
Im working personally in finance, I decided to create personal chart viewing software to suit my needs. I thought I'd create a good part of the backend in Python as it is a language I know quite well. Use Javascript for the graphic side, and use a webview in a windows form to make everything available as if it were software.
As for the graphics I thought of using: Lightweight Library for JS, I find that today it is the most avant-garde library compared to the classic plotly, matplotlib.
Use pywebview as a bridge between Python and JS and to redirect everything in a windows form.
However I find it a bit difficult to use this library (pywebview), there is a poor documentation around and not very clear to me (my level of JS is really basic). However, I believe it is one of the most convenient solutions.
I would have thought of using pyscript, but it still seems early to use this library in production.
Questions:
Do you think such a job is feasible?
Do you know other libraries/better solutions to do such jobs?
What kind of approach would you use if you were to do such work?
What I am trying to achieve is to write most of the functions in python and use only JS to make calls through buttons or to get data from various inputs.
Wandering around the web I found a work already partially created by this guy (if you are reading, Thanks Filipe you have been very helpful! here you can see his project hosted on Github) but unfortunately it is difficult for me to get my hands on a code not produced by me.
I have used Shiny for R and specifically the Shinydashboard package to build easily navigatable dashboards in the past year or so. I have recently started using the Python, pandas, etc ecosystem for doing data analysis. I now want to build a dashboard with a number of inputs and outputs. I can get the functionality up running using Dash, but defining the layout and look of the app is really time consuming compared to using the default layout from the shinydashboard's package in R.
The convenience that Shiny and Shinydashboard provides is:
Easy layout of components because it is based on Bootstrap
A quite nice looking layout where skinning is build in.
A rich set of input components where the label/title of the input is bundled together with the input.
My question is now this:
Are there any extensions to Dash which provides the above functionality, or alternatively some good examples showing how to do the above?
I have similar experience. A lot said python is more readable, while I agree, however, I don't find it as on par with R or Shiny in their respective fields yet.
I have a live feed of data that represents network traffic for a remote machine. I would like to take this data and visualize it in a live plot in my webapp that is using Django, What is the easiest and fast way to achieve this.
What I tried so far: Generating scatter plots using matplotlib and updating the .png image on the webapp
Use RRDTool:
RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data. RRDtool can be easily integrated in shell scripts, perl, python, ruby, lua or tcl applications.
Some examples including web-based system monitoring applications of RRDTool:
http://oss.oetiker.ch/rrdtool/gallery/index.en.html
http://snm.sourceforge.net/
http://munin-monitoring.org/
A good option (I know from first hand experience) is using the Ajax update method with the Flot js library to plot live updating graphs. +1 for simplicity, extensible options, plugins and for the MIT license.
Look at an example here http://people.iola.dk/olau/flot/examples/ajax.html
Cheers!
In the past when I've had to plot data in a browser, I've used jqPlot. You could set javascript up to periodically poll a url on your django app that returns JSON encoded data to plot.
We are a medium-sized academic research lab whose main outputs are new statistical methods for analyzing large datasets. We generally develop in R and MATLAB/Octave.
We would like to expand the reach of our work by building simple, wizard-style user interfaces to access our methods, either web-apps like RNAfold or stand-alone applications to analyze private data.
Ideally, we would like the interfaces to do some data checking, to only use FOSS, to run in Mac and Windows environments, and to be able to generate simple charts and graphs that can be output as figures suitable for publication. Also, we like Python because it’s a popular language in the lab and in our research community.
However, we want to be able to develop and release quickly and cheaply. We are lucky to be able to fund one developer in the lab and s/he has to support multiple projects.
There are a lot of groups with the same needs and constraints as us, so it would be useful to be able to develop a consistent long-term strategy for this type of challenge.
Edit
I asked for comments on four possible approaches, included below with summary of comments:
Calling the R and Octave methods from Python.
Answers:
R / Python integration
Rpy (from ChrisC)
pyRserve (from radek)
PypeR (from radek, see answer for paper link)
Using a Python client to call in to an Octave server (from ChrisC)
Re-implementing our methods in Python. In general, this is not easy because our methods rely on other methods also implemented in R and Octave.
Answers:
There was no comment on this approach, it's probably a bad idea.
Using a different framework to build user-interfaces.
Answers:
How about building GUIs and web-apps directly in R? (from hadley, see answer for tool refs)
Other ideas that we haven’t considered, e.g., integrating with workflow management systems like Taverna.
Answers:
Try a visual programming interface like RedR (from chrisamiller)
My preferred answer
I'm first going to look into the approach suggested by Spacedman: using QtDesigner to build the UI for PyQt4 and calling R with RPy. We get a lot of students without a programming background who want to volunteer in the lab, and QtDesigner looks like something that we could train them to use effectively.
I would like develop GUIs directly in R as recommended by hadley but RQt, which I presume that I need to use QtDesigner, does not appear to be in active development (last update was summer of 2009).
Also, it looks like we may have to start implementing our methods exclusively in R, and translating over from MATLAB/Octave to R. In my field, this is probably not a bad idea anyways.
Appendix:
Python libraries to simplify user interface construction:
wxPython (ChrisC)
PyQt4 (from Spacedman)
Other projects that integrate Python, R, and Octave:
SAGE (Dirk Eddelbuettel)
Shogun (Dirk Eddelbuettel)
GUIs to make GUIs:
QtDesigner with PyQt4 (from Spacedman). Note Qt4 is both commercial and available under a LGPL.
Why not continue to develop directly in R? There are a number of packages that allow you to develop GUIs (gWidgets RGtk, tcl/tk, RQt, Rwxwidgets, rjava) or web applications.
I'd go with Python and PyQt4 for the UI, and use Rpy to interface to R.
There's the QtDesigner for interface designing and you can generate python from that. QtAssistant gives you a fully hyperlinked documentation set for Qt which is the best I've ever used.
Well worth it!
That's a tall order -- multi-platform, multi-backend (R and Ocatve), as well and cheap, fast and easy to use!
From the top of my head, look at these
Sage: they have what they call notebooks which are interactive web pages and showed a nice demo at useR! 2010; I think Octave is covered too
Shogun: which also integrates to Python, R and Octave and may have some tools for you to leverage.
I've been looking for something similar - simple rapid GUI in R. It seems there's a new alternative from RStudio guys.
Shiny should be sufficient for small web interfaces without much coding. Seems like a viable option if you need a simple input/output style of UI.
I haven't tried directly connecting Octave with Python beyond setting up Octave apps as a server and having a Python client call in, but I've had some luck integrating R with Python courtesy RPy. In some of our applications we build e.g. a wxPython + matplotlib Python frontend, and call the R scripts directly through RPy.
For R and Python integration you might also want to have a look at
pyRserve
PypeR [more in the paper]
You might try looking at RedR, which lets you wrap R packages in a Python GUI.
I'm currently using Open Flash Chart 2 on my django website, but I find it insufficiently customizable. (It's great when you want the usual barcharts, piecharts, but what about homemade shapes...). Although it's open source, I don't feel like diving in the Flex code.
I'm thinking a lot about matplotlib but the documentation is rather poor on web application developpment.
Does anybody uses matplotlib in his web app?
I would appreciate links on those web sites to figure out what can be achieved.
Thanks
If you're looking for flash-like interactivity in a web application, matplotlib probably isn't what you're looking for. It's fine for rendering a static image to serve out in a web app, though. (and is amazingly flexible)
However, there's been a lot of recent development on making matplotlib more oriented toward web interactivity. Take a look at the new HTML5/Canvas backend. http://code.google.com/p/mplh5canvas/ It's not quite finished yet, but it's worth playing around with, anyway.
You can use MPLD3 to export your existing matplotlib stuff to browser.
Matplotlib itself is very powerful, albeit, I agree the documentation is not very extensive.
I've learned it just by trying stuff out and finding examples on the net.
'matplotlib example X' where X is somewhat about what you are trying to plot find suprising amount of code on the net.
I have never used matplotlib, but how about using Google's Chart API http://code.google.com/intl/pl-PL/apis/chart/ for charts?
Resurrecting an old question with the current state of affairs. As of Fall 2013, there's now an example of embedding matplotlib's WebAgg backend in a Tornado-based webserver: https://github.com/matplotlib/matplotlib/blob/master/examples/user_interfaces/embedding_webagg.py
This makes use of websockets to send the figure updates to the browser, which allows for really nice interactive plots that get rendered client-side. This means that no images are being generated on the server!
This tool is nice, but it would awesome if it worked with matplotlib.
http://www.highcharts.com/