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.

I would like to increase the vertical length of a node in a way that it can also stretch outside of my image. Moreover, I need to choose different color for each line.

\documentclass{article}
\usepackage{graphicx} % more modern
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{figure}
\vspace{0.5cm}
\centering
\begin {tikzpicture}
\begin {axis}[
title=LastFM,
width=\textwidth,
height=5cm,
grid=both,
unbounded coords=discard,
ylabel=Distance,
xlabel=Days,
]
\addplot+[color=black,sharp plot, mark=none] coordinates{(1,123.247718031613)    (2,111.79445424528)(3,117.439346047226)(4,111.588529876507)(5,110.715852523476)(6,107.172757732551)(7,114.908659377786)(8,129.313572373514)(9,133.656275572829)(10,138.246157270284)(11,125.865007051205)(12,128.171759760097)(13,108.148046676766)(14,119.063008529098)(15,120.166551086398)(16,108.554133960895)(17,128.241958812239)(18,125.650308395961)(19,122.237473795886)(20,110)(21,107.990740343791)(22,113.877126763894)(23,125.283678106927)(24,130.107647738325)(25,131.818056426273)(26,134.476763792114)(27,101.133575038164)(28,119.674558699834)(29,116.952982005591)(30,117.413798166996)(31,110.571244001323)(32,104.019228991567)(33,95.9374796416917)(34,103.923048454133)};
\node[coordinate,pin=above:{10}] at (axis cs:16,128.241958812239) {};
\node[coordinate,pin=above:{10}] at (axis cs:37,117.524465538032) {};
\end{axis}
\end{tikzpicture}
\label{fig}
\caption{My Results}
\end{figure}
\end{document}

Result:

Result

share|improve this question
    
Thanks buddy for your reply! However, I'm afraid to tell you that clip=false didn't change anything! Regarding my second question, I meant the two vertical lines that I indicated with label "10". I want each vertical lines to have different color, for instance the first vertical line in time 16 would have a green color and the second one in time 37 has a blue color and so on. If you take a quick glance at the following paper in page 2, I bet you'll get what I mean with all these words! helpful link! –  Yaser Kenesh Jan 27 '13 at 11:25
add comment

1 Answer 1

Answer the Unanswered...

You can use different coordinate systems such as axis cs, axis coordinate cs: etc. Please check the manual for even more systems. Here is a slightly overkill solution to demonstrate different options. To be able to extend the drawing area the clipping action of the axes must be turned off for this solution via clip=false.

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{figure}
\centering
\begin {tikzpicture}
\begin {axis}[
title=LastFM,
width=\textwidth,
height=5cm,
grid=both,
unbounded coords=discard,
ylabel=Distance,
xlabel=Days,
clip=false
]
\addplot+[color=black,sharp plot, mark=none] coordinates{(1,123.247718031613)    (2,111.79445424528)(3,117.439346047226)(4,111.588529876507)(5,110.715852523476)(6,107.172757732551)(7,114.908659377786)(8,129.313572373514)(9,133.656275572829)(10,138.246157270284)(11,125.865007051205)(12,128.171759760097)(13,108.148046676766)(14,119.063008529098)(15,120.166551086398)(16,108.554133960895)(17,128.241958812239)(18,125.650308395961)(19,122.237473795886)(20,110)(21,107.990740343791)(22,113.877126763894)(23,125.283678106927)(24,130.107647738325)(25,131.818056426273)(26,134.476763792114)(27,101.133575038164)(28,119.674558699834)(29,116.952982005591)(30,117.413798166996)(31,110.571244001323)(32,104.019228991567)(33,95.9374796416917)(34,103.923048454133)};
\draw[red,shorten <=-5mm] ({axis cs:16,120} |- {axis description cs:0,0}) -- ([yshift=5mm]{{axis cs:16,120} |- {axis description cs:0,1}}) node[above] {$10$};
\draw[green,shorten <=-5mm] ({axis cs:37,120} |- {axis description cs:0,0}) -- ([yshift=5mm]{{axis cs:37,120} |- {axis description cs:0,1}}) node[above] {$10$};
\end{axis}
\end{tikzpicture}
\label{fig}
\caption{My Results}
\end{figure}
\end{document}

enter image description here

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.