Complex plotting demo
Try to get the demo.py to work. It draws 3d scatter plot with live data, you should be able to rotate by dragging the mouse; q
should cleanly exit (closing the figure should not).
It should look like this (speed and fluency may vary):
The matplotlib
library handles the plotting by using different backends: combination of a GUI toolkit (Tk
, Qt5
, Qt4
, GTK3
, GTK
or wx
) and a renderer (Agg
, Cairo
or sometimes toolkit-native, with no suffix). The matplotlib.use('…')
line in the beginning of demo.py
or util.py
selects a backend. If one is not provided, matplotlib
selects a reasonable combination which has the necessary libraries present.
Figures embedded in GUIs usually only have limited functionality and don’t update during execution. Launch python3 file.py
directly from a console if you encounter such problems. (Or persuade your GUI to let the figures float free, e.g. %matplotlib notebook
for Jupyter.)
Lab computers
Windows
- Start menu > Anaconda > prompt >
python
:- backends
TkAgg
,Qt5Agg
(default) work
- backends
- Start menu > Anaconda > spyder:
- interactive plots just won’t work (for me, anyway)
- Start menu > Anaconda > Jupyter:
- start with
%matplotlib notebook
(interactive HTML/JS figures) - remove
waitforbuttonpress(…)
fromutil.py:88
- start with
- Start menu > Python 3.6
- needed libraries are not installed
- may work with
pip install --user numpy scipy matplotlib
Linux
- “Start” menu > Konsole >
python3
:- backends
TkAgg
,Qt5Agg
(default),GTK3Cairo
work
- backends
Self-installation
Get a working Python 3.5+ going. Stir in numpy
, scipy
and matplotlib
(probably using pip3 install
; add a pinch of --user
if you’re not an admin).
Alternatively: get an Anaconda 3.5+ installer bundle, which includes all of the above.
Linux
easy:
tk
bindings are included in default Python.agg
is included inmatplotlib
.medium: install
pyqt5
/pyqt4
for Qt5Agg / Qt4Agg backendshard: get
wx
,gtk2
,gtk3
to work with Python 3.*why bother: get
pycairo*
to work
Windows
easy:
tk
bindings are included in default Python.agg
is included inmatplotlib
.hard: install
pyqt5
,pyqt4
,wx
,gtk3
orgtk2
why bother: get
pycairo*
to work
MacOS X
No idea. Default pycharm(?) doesn’t work properly.