The Living Thing / Notebooks :

Plotting in python

Colourizing your data for science

See also diagrams.

Just imagine that we could have a language that combined high-performance numerical operations, interactive debugging, effortless integration of realtime and non-realtime interaction, easy parallelism, a large and active user community, ran on windows, linux, OS X and smartphones, had well-documented, performant graphics and smooth GUI integration.

Now, welcome to the real world, where every project is either

I’m going to try to get some data visualisation going in python via the hodgepodge method. I’d like it to be real-time and interactive or publication-quality, but I won’t be sad if I can’t achieve both simultaneously.

Visualisation is not especially a strong point of the python; the strong point is hodgepodge, decoupage, bricolage, and, uh, potpourri. I think we can cobble something together, or better, use someone else’s cobbling.

Matplotlib

The classic option is matplotlib although it can’t yet do all your modern hipster graphs and is awful at animations and interactions, and it fugly per default. However, there are less screamingly heinous libraries which leverage matplotlib as a backend:

The mpld3 package is extremely easy to use: you can simply take any script generating a matplotlib plot, run it through one of mpld3’s convenience routines, and embed the result in a web page.

2d only, AFAICT.

Read Jakevdp’s manual

Fonts

Someone made the idiosyncratic choice that default font is sans serif, even for mathematical text. You can change this by setting serif fonts also for mathtext.

from matplotlib import rc
rc(
  'font',
  family='serif',
  serif=['Palatino']
)
rc(
  'mathtext',
  fontset='cm'
)

Supported math fonts are reputedly

Alternatively you can render your graph labels with TeX which leads to some weird spacing but allows you to match fonts better.

GR

GR.py wraps GR, a cross-platform visualisation framework:

GR is a universal framework for cross-platform visualization applications. It offers developers a compact, portable and consistent graphics library for their programs. Applications range from publication quality 2D graphs to the representation of complex 3D scenes.[…]

GR is essentially based on an implementation of a Graphical Kernel System (GKS) and OpenGL. […] GR is characterized by its high interoperability and can be used with modern web technologies and mobile devices. The GR framework is especially suitable for real-time environments.

It will also function as a matplotlib backend.

Visdom

Visdom pumps graphs to a visualisation server.

Holoviews

Holoviews has been crafted by some neurologists to serve science. Fresh, enthusiastic.

HoloViews focuses on bundling your data together with the appropriate metadata to support both analysis and visualization, making your raw data and its visualization equally accessible at all times. This process can be unfamiliar to those used to traditional data-processing and plotting tools, and this getting-started guide is meant to demonstrate how it all works at a high level. More detailed information about each topic is then provided in the User Guide .

With HoloViews, instead of building a plot using direct calls to a plotting library, you first describe your data with a small amount of crucial semantic information required to make it visualizable, then you specify additional metadata as needed to determine more detailed aspects of your visualization. This approach provides immediate, automatic visualization that can be effortlessly requested at any time as your data evolves, rendered automatically by one of the supported plotting libraries (such as Bokeh or Matplotlib).

Part of a suite of visualisations tools and guides called Pyviz.

Python+browser

jupyter notebooks have a rich enough API to integrate various more exotic graphics options; In fact, since you are now using the web browser, you can go straight into browser datavis, which is powerful-ish and super hip.

Here are some promising hacks

Related: create your geographic visualisations using python + leaflet.js javascript maps using folium.

network-specific stuff

browser datavis lists Sigma.js; there are surely more JS graph visualisations.

VisPy

VisPy is OpenGL-backed data visualisation, focussing on science (ooh!). It also offers a matplotlib compatibility layer. Here are some howtos:

There seems to be a lot more writing of OpenGL shaders than one would like to draw a line graph.

Mayavi

Mayavi is an opinionated open-source commercially-backed interactive 3D visualiser. Its aesthetic I find grating. The source code repository is worryingly hard to find. For future reference, it’s here.

On a similar tip, although looking more basic and more bitrotten, is vtk - if I understand correctly, VTK is the engine used by Mayavi? * Better maintained and possibly still vtk-based is Paraview, which supports pluggable backends.

Not exactly graph libraries per se

matplotlib stunts