4

I am plotting some 2D data from a file using pgfplots. Is it possible to automatically get (ymin,ymax) and (xmin,xmax) from the file I am trying to plot? I don't want to keep changing these each time I plot a different file.

Not setting these ranges will leave some undesired white spaces in my plots.

8

To prevent PGFPlots from adding padding around your data, set enlargelimits=false:

\documentclass[]{article}

\usepackage{pgfplots}

\begin{document}
Default settings:

\begin{tikzpicture}
\begin{axis}
\addplot table {
3 2
5 3
9 11
};
\end{axis}
\end{tikzpicture}

\hspace{2cm}


With \verb|enlargelimits=false|:

\begin{tikzpicture}
\begin{axis}[enlargelimits=false]
\addplot table {
3 2
5 3
9 11
};
\end{axis}
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.