Installing TikZ and pgfplots
The ConTeXt distribution comes with MetaPost, a powerful graphical programming language, further extended by MetaFun. It also supports TikZ and Pgfplot as third-party modules, making it easy to include existing or new PGF figures in a document. This page briefly describes how to install the latter two to be used from ConTeXt.
Installing TikZ
The easiest way is probably to download the PGF GitHub repository: https://github.com/pgf-tikz/pgf and copy its content to your TEXMF directory (where your ConTeXt distribution is installed), then run mtxrun --generate
.
Released versions (https://github.com/pgf-tikz/pgf/releases) can be installed similarly.
Installing Pgfplots
Pgfplots can be installed similarly from either the main branch of the pgfplots repository (https://github.com/pgf-tikz/pgfplots) or one of the official releases (https://github.com/pgf-tikz/pgfplots/releases/).
As of 17 July 2024, there were minor issues when using Pgfplots (main branch) from ConTeXt. Some of them may be resolved as follows:
- In the file
tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex
, add the following after line 2806:
\if0\pgfplotsretval \def\pgfplotsretval{5} \fi
- In the file
tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-luatex.def
, delete\immediate
on lines 64, 125, and 144.
- In the file
tex/generic/pgfplots/sys/pgflibrarypgfplots.surfshading.pgfsys-pdftex.def
, delete\immediate
on lines 57 and 119.