|
| 1 | +A (new) cairo backend for Matplotlib |
| 2 | +==================================== |
| 3 | + |
| 4 | +This is a new implementation of a Cairo backend for Matplotlib. Currently, it |
| 5 | +is designed to be used with the qt-cairo backend proposed in Matplotlib's |
| 6 | +PR #8771. |
| 7 | + |
| 8 | +Installation |
| 9 | +------------ |
| 10 | + |
| 11 | +Only Python 3 is supported. A very recent C++ compiler, with support for C++17 |
| 12 | +(e.g., GCC 7.1) is required. |
| 13 | + |
| 14 | +Run:: |
| 15 | + |
| 16 | + $ python -mvenv /path/to/venv |
| 17 | + $ source /path/to/venv/bin/activate |
| 18 | + $ git clone https://github.com/matplotlib/matplotlib.git |
| 19 | + $ git pull origin pull/8771/head:pr/8771 |
| 20 | + $ git checkout pr/8771 |
| 21 | + $ pip install -ve . |
| 22 | + $ git clone https://github.com/anntzer/mpl_cairo.git |
| 23 | + $ pip install . |
| 24 | + |
| 25 | +Then, run, e.g.:: |
| 26 | + |
| 27 | + import mpl_cairo; mpl_cairo.install() |
| 28 | + import matplotlib; matplotlib.use("qt5cairo") |
| 29 | + |
| 30 | + data = [[0.5, 0.525, 0.55, 0.575, 0.6, 0.625], |
| 31 | + [0.5, 0.501, 0.502, 0.503, 0.504, 0.505]] |
| 32 | + |
| 33 | + fig, ax = plt.subplots(figsize=(3.5, 3.5)) |
| 34 | + fig.subplots_adjust( |
| 35 | + left=0.01, right=0.99, bottom=0.01, top=0.99, hspace=0, wspace=0) |
| 36 | + ax.set(xlim=(0, 1), ylim=(0, 1)) |
| 37 | + ax.scatter(data[0], data[1], s=25) |
| 38 | + |
| 39 | +and compare the marker position with the default ``qt5agg`` backend. |
| 40 | + |
| 41 | +What about the already existing cairo (gtk3cairo) backend? |
| 42 | +---------------------------------------------------------- |
| 43 | + |
| 44 | +It is slow (try running ``examples/mplot3d/wire3d_animation.py``), buggy (try |
| 45 | +calling ``imshow``, especially with an alpha channel), and renders math poorly |
| 46 | +(try ``title(r"\sqrt{2}")``). |
0 commit comments