Live Graphs On Django - python

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.

Related

Python web app for programmatic 3D scene construction

I'm currently developing a Django app that allows students to programmatically develop SVG graphics. They can code Python in their browser with ACE editor. The code is executed on the server, stored in a database and the generated SVG (custom library) returned and displayed. An example code that displays a filled ellipse looks like so:
graph.draw(Circle(cx=0, cy=0, r=20, fill="lime").scale(2, 1)
Now I'm wondering, how I could extend this app to do some 3D. I stumbled over X3Dom, which seems promising and not too hard to generate and I could write another lightweight pythonic library for this. But, it doesn't seem to do CSG (constructive solid geometry) which is major drawback.
Any hints in what direction I should investigate for some 3D web technology that allows easy 3D scene generation with server-side python and that implements CSG?
NB: OpenJSCad is simalar to what I'd like to achieve, except that my solution allows for classroom collaboration and it must expose Python to students as the programming language. The aim is to spice up the teaching of Python programming with graphics.
I believe I used three.js to do CSG a while back. There used to be an example online. You are right that X3D does not do CSG. I was doing cross sections of the earth and found a way with X3D. You might be able to use VPython or brython in the browser if your worried about Python not running in the browser. I’ve only brython for a short time testing another person’s project and vpython not at all.
If you’re doing something like inverseCSG or CSGNet, is your class available online?
In other words, maybe try to find a Python library that does CSG instead searching for a rendering engine in JS. Don’t view the browser as limited to JS.
I only found three.js when I was looking.
Maybe search for a solution which is not a solid solution.
try checking out the library "trimesh" for python which relays mainly on watertight stl files, but allows you to do some boolean operations for CSG. You can substract one file from the other, extended and find the intersection. Plus, it has some primitive functions directly like cylinders and spheres.

Interactive Data Visualiation - Python

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.

interactive online data plotting using python

Question: is it possible to recreate such functionality with python? http://itools.subhashbose.com/grapher/index.php
Backstory: We want to create a hybrid online teaching/computational resource for undergraduate students of our institute, running on a local server. I have worked only in matlab, and have fair bit experience in c++. so wanted to choose appropriate language (preferably open source, but not strictly) which can facilitate above functionality with mathematica cdf like properties. I wanted to learn python form long time so wanted to know if it can do the job. Dont want to use javascript (which i suppose is used in this page).
For fetching data from html have a look at this site: http://docs.python.org/2/howto/urllib2.html.
If you want to built your own site, there are small web frameworks like flask and bottle. If you are interested in a more comprehensive web framework, check out Django: http://www.djangoproject.com/.
Matplotlib could be used to generate the plot e.g. in jpg or svg. The latter might give you the option to have the image respond to e.g. hovering over specific parts of the plot like in your example page.
Maybe also have a look at https://pypi.python.org/pypi/django-chart-tools. From their webpage:
django-chart-tools is a simple app for creating charts in django templates using Google Chart API.

web based visual programming interface based on python for data visualization

I just discovered impure.com and was very impressed by what can be achieved in terms of visualizing data using their workspace. Although the platform is free to use, but not open source yet. This causes a few problems because the API section works with .com sites for eg. for ebay, so I cannot visualize ebay listings for regional sites such as ebay.in because the link to ebay.com is hardcoded.
I searched around, but didn't find other projects that offer a similar way to work with site APIs and other data sources with the kind of user interface and detail that impure.com does in a realtime way within a browser window.
This brings me to the questions:
What technologies would be involved in creating a similar kind of project
What are the open source tools that can help develop a fullscreen UI to render the workspace. Are there any alternatives to flash for this, and how do they compare
The goal would be to use standard python data structures, python scripts to do some processing on these data structures, scripts to gather data from csv, json and API sources such as google yahoo, wikipedia and flickr, and scripts to render graphs, tag clouds, network visualizations etc. Then bring them all together into a visual interface that supports drag drop and simple type checking
How would the python backend integrate with the UI
sorry for the rambling question, but i wanted to present as much detail as possible. I'd like to do this for the fun of it
So, restating, Impure is like OpenDX but running in a browser and you are interested in suggestions for an architecture to build your own web version of it?
I suggest using Cappuccino as your front end Web GUI. This is a toolkit for building RIAs in the browser that are completely based on HTML and Javascript (no Flash). It is modeled after Apple's Cocoa so you can build some very sophisticated apps with it.
On the web server side, I would use the Python bindings to OpenDX to build a JSON API that is exposed to the web browser. Note, this Python module uses DXLink, which appears to be mainly a batch/command interface to OpenDX - you might still need to do some work to get visualizations out of it and back to the web browser. But, it's all open source so it should be feasible. Here's a discussion where others are attempting the same thing.
I don't know for sure that OpenDX supports pulling data via web service calls but you could certainly handle that on the Python side and feed it into OpenDX.
Note, I don't mention a Python web framework because, since your app will be mostly a JSON API almost any of them would work just as well. I suggest the thinnest and simplest one that appeals to you.

Matplotlib: interactive plot on a web server

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/

Categories