📜 ⬆️ ⬇️

Drawing charts in Chaco

Today I will tell you about a wonderful program called Chaco, which is being developed by Enthought.

Chaco is a cross-platform Python graphics application of any complexity. It focuses on rendering static data, but it also has the ability to create animations.


')
Just like Mayavi, it can integrate into Wx and Qt (PyQt and PySide) applications and is friendly with Numpy arrays.


Installation

The first step is to install Chaco. We put dependences: git, subversion, setuptools, swig, numpy, scipy, vtk, wxpython. For Windows, you also need to install mingw (vtk and wxpython for Win, I advise you to take from here to save time www.lfd.uci.edu/~gohlke/pythonlibs ). We are picking up ETS products with git (you can remove the unnecessary):

mkdir ets && cd ets
wget github.com/enthought/ets/raw/master/ets.py
python ets.py clone


Then we collect this whole thing:
python ets.py develop


You may have to deliver something else, you need to look at the build logs. What is enough, install and run the assembly again.

Examples

In the ets / chaco / examples folder you can see a large archive of various examples. The examples are very good, so it’s quite difficult for me to explain something, I’ll get a copy-paste code.

I will describe only some unusual graphics that can be built in Chaco:



To see how Chaco implements animation, look in the ets / chaco / examples / updating_plot folder


Chaco to HPGL-GUI

In HPGL-GUI it was necessary to build histograms. Matplotlib and Chaco were equally suitable for this. The choice fell on Chaco, because Matplotlib did not support PySide integration.
The statistics window looks like this:

The code can be found here:
raw.github.com/Snegovikufa/HPGL-GUI/master/gui_widgets/statistics_window.py

PS If you need to tell about embedding in PyQt4 or PySide, then I will add.

UPD. Updated financial chart example: added detailed comments and made embedding in the PySide widget.

Source: https://habr.com/ru/post/118280/


All Articles