Insert a PGF Plot File to Latex: A Step Guide – Latex Tutorial

By | November 23, 2020

Inserting a pgf file is a good way to insert images in latex. In this tutorial, we will introdue you how to insert it.

Preliminary

You can create a pgf file to contains your plot. Here is an example:

Matplotlib Generate PGF File: Create a PGF Plot – Matplotlib Tutorial

In this tutorial, we have created a test.pgf file, we will start to insert it to latex.

Insert pgf to latex

Here is an example code to insert pgf to latex.

% your document class here
\documentclass{article}

\usepackage{pgf}

\begin{document}

\begin{figure}
    \begin{center}
        \input{test.pgf}
    \end{center}
    \caption{A PGF test from \texttt{matplotlib}.}
\end{figure}
\end{document}

Then you can find the result:

Matplotlib Generate PGF File - Create a PGF Plot - Matplotlib Tutorial

Meanwhile, we can find the text in graphic is also enlarged if you enlarge the pdf file.

insert pgf to latex

Leave a Reply