Matplotlib 2 in Cygwin 64-bit for Python 3 and Python 2.7

less than 1 minute read

Related: easy pip install matplotlib without commpling

Matplotlib Cygwin manual compile

This method is NOT normally needed.
Just python -m pip install matplotlib normally.

  1. at Windows Command Prompt:
    setup-x86_64 -P pkg-config ghostscript libfreetype-devel libpng-devel libgtk2.0-devel gcc-g++ git openbox python3-numpy python3-pyqt5 python3-devel
  2. at Cygwin Terminal:
    python -m pip install matplotlib

Alternative: Matplotlib compile

You can just use the process above, unless you want to compile Matplotlib on Cygwin from source code for the latest Matplotlib beta.

git clone git://

python -m pip install -e .



Python 3.6.1

import matplotlib


visible figures

To create visible Matplotlib figures in Cygwin, start the X11 system by:

  1. Windows Start button → All App → Cygwin-X → Openbox.
  2. Openbox desktop: Right click → Terminals → Xterm.

Test the Matplotlib / Cygwin-X / Openbox configuration from the Cygwin X11 Openbox Xterm terminal:

from numpy.random import rand
import matplotlib

matplotlib.use('qt5agg') #must be before other matplotlib commands

from matplotlib.pyplot import figure,show


You can permanently set default Cygwin Matplotlib backend to qt5agg.

Save figures

Even without the X11 desktop, create and save invisible figures to .eps, .png, .svg, etc. by using savefig().

from matplotlib.pyplot import figure,show


Leave a Comment