Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
2  
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
add comment

1 Answer

up vote 2 down vote accepted

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.