Matplotlib in Cygwin for Python

This method is specific to Cygwin; normally instead use Matplotlib from native Windows Python install.

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

At Cygwin Terminal:

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

pip install -e .


It’s important to actually try to make a figure, not just import matplotlib as some errors only occur when the libraries are actually invoked.

from matplotlib.pyplot import figure, show

ax = figure().gca()

This may not open a visible figure unless X11 is started as noted in the section below.

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
from matplotlib.pyplot import figure,show


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


easy pip install matplotlib without compiling