# Pgfplots axis refuses log

I'm working on a (magnitude) Bode plot and for some reason the x-axis wont go into log mode. I would like the x-axis to go from 10Hz to 200Hz. When I change xmax=1000 the plot is in the right format, but not the right axis range. If I then change back to xmax=200 the x-axis is no longer in log mode. Also the ticks change when I go to xmax=200. (I would only like 10^1, 10^2 but with xmax=200 the ticks 10^1.1, 10^1.2 etc. appear)

Here is my code (I've omitted the data). Hope it is readable, copying from texstudio to this post completely messes up the formatting.

\documentclass[]{article}
\usepackage{pgfplots}

\begin{document}

\begin{figure}[]

\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}
\definecolor{mycolor2}{rgb}{0.85000,0.32500,0.09800}
\definecolor{mycolor3}{rgb}{0.92900,0.69400,0.12500}
\definecolor{mycolor4}{rgb}{0.49400,0.18400,0.55600}

\begin{tikzpicture}

\begin{axis}[
width=12.8cm,
height=3cm,
at={(0.596in,1.66in)},
scale only axis,
separate axis lines,
every outer x axis line/.append style={white!40!black},
every x tick label/.append style={font=\color{white!40!black}},
xmode=log,
xmin=10,
xmax=200,
xlabel={Frequency (Hz)},
xmajorgrids,
xminorgrids,
every outer y axis line/.append style={white!40!black},
every y tick label/.append style={font=\color{white!40!black}},
ymin=-80,
ymax=0,
ylabel={Magnitude (dB)},
ymajorgrids,
axis background/.style={fill=white},
legend style={legend pos=south west,legend cell align=left,align=left,draw=white!15!black}
]

\end{axis}
\end{tikzpicture}
\end{figure}

\end{document}


I think you get the undesired result because of (at least for a log plot) the very small x range. To overcome this issue you can add the xticks yourself/by hand, either by using the xtickten key, which requires fewer computational time or by using xtick itself.

(Please note that I reduced your code to the absolute minimum - so it is now a real MWE - so the key point can be tracked more easily.)

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=10,
xmax=200,
xmode=log,
% just a dummy plot so xticks' show up as wanted
`