# pgfplots semilog axis limits

I read in some posts (here is one) that if I'm using semilogxaxis in order to limit the domain to [10^a, 10^b] I should give as limits a:b:

\begin{semilogxaxis}[
restrict x to domain = -1:1,
% this should limit x to [0.1,10]
]
\end{semilogxaxis}


However, my code behaves differently, and it seems that it takes as limits an approximation of [e^a, e^b]. More precisely, if I write restrict x to domain = -5:-.5 the axis limits become 0.007:0.5. which are close to e^-5:e^-0.5, that is 0.00673:0.6065.

Does anyone understand the weird way limits are computed?

This is close to my original code (I cannot include the data as it's a big file):

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{graphicx}
\begin{document}
\begin{tikzpicture}[
every axis/.style = {
axis x line=center,
axis y line=left,
clip=false,
restrict x to domain = -5:-0.5,
restrict y to domain = -20:20,
}
]
\begin{semilogxaxis}
% plots
\end{semilogxaxis}
\end{tikzpicture}
\end{document}

• Please provide a complete MWE that can be compiled such that others don't have to guess your preamble and so on. – user121799 Dec 12 '18 at 16:24
• Did you give log basis x = 10 ? – nidhin Dec 12 '18 at 16:24
• @marmot I can't create a MWE that gaves the same results as I should include a pretty big data table, however I added the code of the axis environment without plots that gives me the same results if I add the plots. – Taekwondavide Dec 12 '18 at 16:38

By default, semilogxaxis uses e=2:71828 as basis. If you need any other basis, it has to specified with log basis x.
• Thank you! I assumed that, seeing 10^x as thick labels, the basis were 10. However, do you know how limits were approximated when I was using e basis? – Taekwondavide Dec 12 '18 at 16:45
• I don't think there is any approximation. e^-5=0.00673794699 and e^-0.5=0.60653065971. – nidhin Dec 12 '18 at 16:49
• I have now set -2.2:-0.2 as limit (with basis 10). I wrote \addplot coordinates {(10^-2.2,-3) (.2,-3)} and the first point is outside the limits (the plot does not appear), but if I replace first x coordinate with 10^-2.1 it works. Do you know if there is a way to make the limits inclusive? – Taekwondavide Dec 12 '18 at 16:50
• @Taekwondavide I think then the upper limit is not included in semilogxaxis. For linear x axis, upper limit is also included. – nidhin Dec 12 '18 at 17:22