I was wondering if anyone has had the same results which I'm having when using the library units
from pgfplots
. When the options change x base=true, x SI prefix=milli
are used, pgfplots
seems to put an 'extra' whitespace under the x axis. Here is a MWE:
\documentclass[class=IEEEtran]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{units}
\usetikzlibrary[backgrounds]
\definecolor{graphicbackground}{rgb}{0.96,0.96,0.8}
\begin{document}
\begin{tikzpicture}[tight background ,show background rectangle,
background rectangle/.style={fill=graphicbackground}]%
\begin{axis}[%
scale only axis,
xlabel={$t$ (ms)},
ylabel={$f(t) = t^2 - t +4$},
xmin=1.8E-3, xmax=8.5E-3,
ymin=-8.5, ymax= -2.5,
axis x line=bottom,
axis y line=left,
axis line style = {-latex},
change x base=true, x SI prefix=milli,
every axis x label/.style={at={(ticklabel* cs:1.0)},anchor=south east},
]%
\addplot[color=red,mark=x] coordinates {
(2E-3,-2.8559703)
(3E-3,-3.5301677)
(4E-3,-4.3050655)
(5E-3,-5.1413136)
(6E-3,-6.0322865)
(7E-3,-6.9675052)
(8E-3,-7.9377747)
};
\end{axis}%
\end{tikzpicture}
\end{document}
Which produces the following:
As opposed when the x-axis is in the range from '0' to '10', in which case the 'units' library is not used
\documentclass[class=IEEEtran]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{units}
\usetikzlibrary[backgrounds]
\definecolor{graphicbackground}{rgb}{0.96,0.96,0.8}
\begin{document}
\begin{tikzpicture}[tight background ,show background rectangle,
background rectangle/.style={fill=graphicbackground}]%
\begin{axis}[%
scale only axis,
xlabel={$t$ (ms)},
ylabel={$f(t) = t^2 - t +4$},
%xmin=1.8E-3, xmax=8.5E-3,
xmin=1.8, xmax=8.5, % <- new x values
ymin=-8.5, ymax= -2.5,
axis x line=bottom,
axis y line=left,
axis line style = {-latex},
%change x base=true, x SI prefix=milli,
every axis x label/.style={at={(ticklabel* cs:1.0)},anchor=south east},
]%
\addplot[color=red,mark=x] coordinates {
(2,-2.8559703) %<- x values changed
(3,-3.5301677)
(4,-4.3050655)
(5,-5.1413136)
(6,-6.0322865)
(7,-6.9675052)
(8,-7.9377747)
};
\end{axis}%
\end{tikzpicture}
\end{document}
which outputs the following:
Notice in the last image there is less whitespace under the x-axis. Does anyone knows what might be causing this? and how can I get rid of this extra whitespace? I would appreciate your comments.