1

I'm plotting a exponential function and I need to point out some specific values in my plot.

Point name (x;y)

Point N1 (2;50)

Point N2 (4;25)

I'm trying to follow Gonzalo Medina's answer but I am not getting any success

\begin{figure}[H]
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
    domain=10:1,
    axis lines=left,
    grid=both,
    clip=false,
    xlabel=$Tempo (dias)$,
    ylabel=$Atividade (Ci)$
]
\addplot[name path=curve,smooth,thick,black]{100*exp(-x*ln(2)/2)};
\addplot[name path=line,smooth,dashed,red]{50};
\path[name intersections={of=curve and line, by={a}}];
\draw[dashed] 
  (a) -- (a|-{axis cs:0,0}) node[anchor=north,font=\tiny] {$N=1$};
\node[fill,inner sep=1.5pt] at (a) {};
\end{axis}
\end{tikzpicture}
\end{figure}

Note that I only tried pointing N1 here, and even that doesn't work. Also, I dont want do plot a line just to make the intersection, but I don't know how to do in another way.

Any advice?

erickfis
  • 457
  • Where you like to have written specific value? At point determined by intersection of curves? – Zarko Feb 08 '16 at 14:18

2 Answers2

3

An alternative to Alenanno answer, with nodes name at nodes:

\documentclass[margin=10pt]{standalone}
    \usepackage{pgfplots}
    \pgfplotsset{compat=1.13}

\begin{document}
    \begin{tikzpicture}[scale=1.5,
X/.style = {circle, fill=black, inner sep=1.5pt, 
            label={[font=\scriptsize]above right:#1},
            node contents={}}
                    ]
\begin{axis}[
    domain=10:1,
    axis lines=left,
    grid=both,
    clip=false,
    xlabel=\textit{Tempo (dias)},
    ylabel=\textit{Atividade (Ci)}
]
\addplot[smooth,thick,black]{100*exp(-x*ln(2)/2)};
%
\draw[dashed] (1,50) -- (2,50) node[X={$N=1$}] -- (2,3);
\draw[dashed] (1,25) -- (4,25) node[X={$N=2$}] -- (4,3);
\end{axis}
    \end{tikzpicture}
\end{document}

In above code I consider, that the recent pgfplots package is avaliable. In case, that it is before version 1.11, than in coordinates should be added axis cs:, something like (axis cs:1,25).

enter image description here

Zarko
  • 296,517
  • real nice output! thank you! I'm definitely trying once my tex installation its done (just removed everything to update...) – erickfis Feb 08 '16 at 15:22
  • Done! tex updated and pgfplotsset is now 1.13. Your code works like a charm. Thank you! – erickfis Feb 09 '16 at 17:31
1

Normally you'd need intersections to do a good job. There would be other solutions but the ones I can think of require even more code than mere intersections. Still, in your case you don't even need intersections. You can just draw the lines.

Output

enter image description here

Code

\documentclass[margin=10pt]{standalone}
\usepackage{pgfplots}

\pgfplotsset{compat=1.13}

\tikzset{
    dot/.style={fill=black, circle, inner sep=1.5pt},
    nod/.style={sloped, at start, xshift=3mm, font=\scriptsize, above},
}

\begin{tikzpicture}[scale=1.5]
\begin{axis}[
    domain=10:1,
    axis lines=left,
    grid=both,
    clip=false,
    xlabel=Tempo (dias),
    ylabel=Atividade (Ci)
]
\addplot[name path=curve,smooth,thick,black]{100*exp(-x*ln(2)/2)};

\draw[dashed] (2,5) -- (2,50) coordinate[dot] node[nod] {$N=1$} -- (1,50);

\draw[dashed] (4,5) -- (4,25) coordinate[dot] node[nod] {$N=2$} -- (1,25);
\end{axis}
\end{tikzpicture}
\end{document}
Alenanno
  • 37,338
  • With pgflots version 1.133 is not need to use axis cs: in coordinates anymore :-) – Zarko Feb 08 '16 at 14:21
  • @Zarko Didn't know about that! Very convenient. Thanks for the heads-up. – Alenanno Feb 08 '16 at 14:23
  • Houston, we have a problem: I can't compile if pgfplotsset compat isn't set to 1.9 and, using your answer, the points aren't in the right place. Let me upload a picture of it – erickfis Feb 08 '16 at 14:40
  • @Zarko and Alenanno: You may also want to comment on using math mode in the axis labels. They shouldn't be in math mode, as they're just text. – Torbjørn T. Feb 08 '16 at 14:46
  • @TorbjørnT. You're right, I didn't notice that. – Alenanno Feb 08 '16 at 14:46
  • @erickfis Use axis cs:2,5 as in the original version of this answer, then it should work also with compat=1.9. – Torbjørn T. Feb 08 '16 at 14:46
  • @erickfis Aren't you able to use 1.13? Why 1.9? – Alenanno Feb 08 '16 at 14:49
  • updating my tex distribution now on dog slow internet. I'm using this metod: http://tex.stackexchange.com/questions/1092/how-to-install-vanilla-texlive-on-debian-or-ubuntu - I have just removed everything and cannot try anything until its complete =( Tomorrow I'll be back with news – erickfis Feb 08 '16 at 15:20
  • @erickfis As Torbjørn T. said, use (axis cs: ...) for now. – Alenanno Feb 08 '16 at 15:25
  • Done! tex updated and pgfplotsset is now 1.13. Your code works like a charm. Thank you! – erickfis Feb 09 '16 at 17:29