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.

First of all, let me apologize if the title is not enough clear, but I didn't know how to explain myself better.

I have a graph consisting in three different curves that are covering almost the same y range, except for one point. Since this point corresponds to a value of y much higher respect to the others, I don't want to report it directly, because it would cause the flattening of all the other points. My solution is therefore to report this only point in a separate position of my graph, with an arrow that indicates that it is out of the range and its coordinates:

\documentclass{scrbook}
\usepackage{classicthesis}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[
     xlabel={x},
     ylabel={y},
     xmin=0, xmax=120,
     ymin=0, ymax=5,
     width=.8\columnwidth,
     cycle list name=black white,
     /pgfplots/ytick={1,2,...,5}]
     \addplot
     coordinates{
     (3,    25)
     (5,    4)
     (10,   2)
     (20,   1)
     (40,   0.5)
     };
     \addplot
     coordinates{
     (6,    4)
     (10,   2)
     (20,   1)
     (40,   0.5)
     (80,   0.5)
     };
     \addplot
     coordinates{
     (9,    3)
     (15,   1.5)
     (30,   0.5)
     (60,   0.5)
     (120,  0.5)
     };
     \node at (axis cs:25,4.5) {$\uparrow(3,25)$};
     \legend{1,2,3}
     \end{axis}
\end{tikzpicture}

\end{document}

Here is what I'm asking you:

  • As you can notice, I'm using the \uparrow symbol to create the arrow, but I would like a thinner and longer arrow.
  • I would like not to be obliged to report the coordinates of the point by hand.
  • I would like to add a mark between the arrow and the coordinates, which should have the same style of the first curve.

Thanks for your help.

EDIT:

Although I'm not completely satisfied about it, I adopted the following solution:

\documentclass{scrbook}
\usepackage{classicthesis}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[
     xlabel={x},
     ylabel={y},
     xmin=0, xmax=120,
     ymin=0, ymax=5,
     width=.8\columnwidth,
     cycle list name=black white,
     /pgfplots/ytick={1,2,...,5}]
     \addplot
     coordinates{
     (3,    25)
     (5,    4)
     (10,   2)
     (20,   1)
     (40,   0.5)
     };
     \addplot
     coordinates{
     (6,    4)
     (10,   2)
     (20,   1)
     (40,   0.5)
     (80,   0.5)
     };
     \addplot
     coordinates{
     (9,    3)
     (15,   1.5)
     (30,   0.5)
     (60,   0.5)
     (120,  0.5)
     };
     \draw[-latex] (axis cs:12,4.25) -- (axis cs:12,4.75);
     \addplot[fill=gray,mark=*]
     coordinates{
     (15.5, 4.5)
     };
     \node[right] at (axis cs:16,4.5) {$(3,25)$};
     \legend{1,2,3}
     \end{axis}
\end{tikzpicture}

\end{document}

Here is the result:

Result

share|improve this question

2 Answers 2

An alternative approach could be to use the key restrict y to domain*=0:5.5, which will limit the maximum y value to 5.5, in conjunction with clip=false, which allows plots to extend past the plot boundary. You could then place a label node and a positioning node which can be used for drawing a "break" symbol:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[
     xlabel={x},
     ylabel={y},
     xmin=0, xmax=120,
     ymin=0, ymax=5,
     width=.8\columnwidth,
     cycle list name=black white,
     /pgfplots/ytick={1,2,...,5},
     clip=false,
     restrict y to domain*=0:5.5]
     \addplot
     coordinates{
     (3,    25)
     (5,    4)
     (10,   2)
     (20,   1)
     (40,   0.5)
     } node [pos=0,anchor=west] {(3\,,\,25)}
        node (break) [pos=0.0125,inner sep=0pt,minimum width=0.75em, minimum height=0.5ex,fill=white] {};
     \draw [fill=red] (break.north east) -- (break.north west) (break.south west) -- (break.south east);
     \addplot
     coordinates{
     (6,    4)
     (10,   2)
     (20,   1)
     (40,   0.5)
     (80,   0.5)
     };
     \addplot
     coordinates{
     (9,    3)
     (15,   1.5)
     (30,   0.5)
     (60,   0.5)
     (120,  0.5)
     };
     \legend{1,2,3}
     \end{axis}
\end{tikzpicture}

\end{document}
share|improve this answer
    
would it be better to have the break on the axis with the y-axis range from 0-25 and the break occurring for 5-24? –  Leeser May 2 '12 at 18:06

You could use the resizebox command provided by th graphicx package:

\documentclass{scrbook}
\usepackage{classicthesis}
\usepackage{tikz}
\usepackage{pgfplots}

\usepackage{graphicx}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
     xlabel={x},
     ylabel={y},
     xmin=0, xmax=120,
     ymin=0, ymax=5,
     width=.8\columnwidth,
     cycle list name=black white,
     /pgfplots/ytick={1,2,...,5}]
     \addplot
     coordinates{
     (3,    25)
     (5,    4)
     (10,   2)
     (20,   1)
     (40,   0.5)
     };
     \addplot
     coordinates{
     (6,    4)
     (10,   2)
     (20,   1)
     (40,   0.5)
     (80,   0.5)
     };
     \addplot
     coordinates{
     (9,    3)
     (15,   1.5)
     (30,   0.5)
     (60,   0.5)
     (120,  0.5)
     };
     %  \node at (axis cs:25,4.5) {$\uparrow(3,25)$};
     \node at (axis cs:25,4) {\resizebox{2mm}{10mm}{$\uparrow$}(3,25)};
     %\draw[-latex] (axis cs:25,3.7) -- node[right] {(3,25)} (axis cs:25,4.7) ;
     \legend{1,2,3}
     \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Alternatively, you could also use TikZ to draw the arrow, where you can choose from different arrow tips if you load the arrows library (see this quick reference) via

\draw[-latex] (axis cs:25,3.7) -- node[right] {(3,25)} (axis cs:25,4.7);

enter image description here

share|improve this answer
    
The solution with the LaTeX arrow is really nice! Thanks also for the link to the libraries. Can you help me in solving the other two questions I asked, especially the third (how to add a mark between the arrow and the point coordinates, with the same style of the first curve)? –  mp87 Apr 18 '12 at 21:51
    
@mp87 To be honest, I don't know the answer to either question, and I think it would be best to start a new question regarding this. –  Tom Bombadil Apr 19 '12 at 18:43

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.