# ticks disappearing for diverging (out of range) plots

my xticks disappear for some plots even though I explicitly ask for them. Here is my MWE. The function goes to -infinity at the right border of the interval.

\documentclass{article}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}[domain=0:1]
\begin{semilogyaxis}[xtick={0,0.5,1}]
\addplot[mark=none,samples=300] {x - 1/(4 - 4*x) + 5/4};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}


How do I get them back? A general idea how to deal with the plotting of divergent functions would be great.

-
You'll have to set xmax=1 to make sure that that point is included in your range. The domain keyword only sets the computational range for the \addplot command, but not the visible range of the axis. –  Jake Jan 22 '13 at 17:13

To make sure that all the ticks that you specify using xtick are actually visible, you will have to adjust the axis limits using xmin and xmax, making sure that the tick range is completely covered. In your case, simply saying xmax=1 does the trick.

The domain keyword only sets the computational range, not the visible one. If you use, say, domain=0:100, but xmin=0, xmax=1, the functions given in \addplot commands will be evaluated everywhere between 0 and 100, even though the range from 1 to 99 will not be plotted. Similarly, if you set domain=0:1, xmin=0, xmax=100, the function will only be evaluated (and plotted) between 0 and 1, but the axis will range from 0 to 100, so most of the plot range will be empty.

\documentclass{article}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}[domain=0:1]
\begin{semilogyaxis}[xtick={0,0.5,1}, xmax=1]
\addplot[mark=none,samples=300] {x - 1/(4 - 4*x) + 5/4};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

-