You can accomplish this by adjusting the style of whichever axis' tick labels you wish to adjust (xticklabel style
, yticklabel style
, or ticklabel style
for both axes). Here I assume you wish to modify the y-axis tick labels.
The particular items of interest are
/pgf/number format/fixed zerofill
(fixed format with trailing zeros shown) and
/pgf/number format/precision=1
(display one digit after the decimal separator).
Since these are both in the same "folder", we can save keystrokes by using .cd
to switch into that folder.
Putting this all together, we have
yticklabel style={/pgf/number format/.cd,fixed zerofill,precision=1}
which can be added to the axis
environment options.
Complete Code
\documentclass{memoir}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
% horizontal axis
\begin{axis}[xmin=0,xmax=50,ymin=0.0,ymax=4.0,grid=both,minor tick num=4,
major tick length=0pt,
minor tick length=0pt,
%no markers,
ylabel=Applied Force/N,
xlabel=Length/cm,
yticklabel style={/pgf/number format/.cd,fixed zerofill,precision=1},
every major grid/.style={black,opacity=0.8},
]
\addplot [black] coordinates {
(0,0)
(8,0)
(38,3)};
\end{axis}
\end{tikzpicture}
\end{document}
Output
You can process your tikzpicture
s as standalone documents and then include them as pictures. E.g., the file myplot.tex
might contain
\documentclass[border=0.1cm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[...]
...
\end{axis}
\end{tikzpicture}
\end{document}
Your main document then includes the generated pdfs:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{myplot.pdf}
\end{document}
Best Answer
Actually, thanks to percusse's comment, I researched the pgfplots'
externalize
library and found that adding these two linesto my preamble did just what I wanted for no effort at all!
(Ryan's answer is also great, and thanks to him, but this is a better way.)