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 have the following plot:

\begin{tikzpicture}
    \begin{axis}[grmin=-5:5 -5:5]
        \addplot[mark=none] {x^2/4};
        \addplot[mark=none] {-1};
        \addplot[mark=*] coordinates {(0,1)};
    \end{axis}
\end{tikzpicture}

Which looks like this:

enter image description here

My question is: how can I label the point (0,1) as "(0,1)", such that the label appears either to the right or left of the point?

share|improve this question

3 Answers 3

up vote 15 down vote accepted

You can use the axis coordinate system to refer to actual plot coordinates and it would be great if you can include full compilable code examples as below.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document} 
\begin{tikzpicture}
    \begin{axis}[axis y line=middle,axis x line=bottom]%[grmin=-5:5 -5:5]
        \addplot[mark=none] {x^2/4};
        \addplot[mark=none] {-1};
        \node[label={180:{(0,1)}},circle,fill,inner sep=2pt] at (axis cs:0,1) {};
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Thanks, this is almost perfect. The only change I would make is label={180:{$(0,1)$}} -- putting the coordinate in math mode. –  Xenon Mar 24 '13 at 12:50

You may be looking for TikZ's pin option, used like so:

\begin{tikzpicture}
    \begin{axis}[grmin=-5:5 -5:5]
        \addplot[mark=none] {x^2/4};
        \addplot[mark=none] {-1};
        \addplot[mark=*] coordinates {(0,1)} node[pin=150:{$(0,1)$}]{} ;
    \end{axis}
\end{tikzpicture}

enter image description here

share|improve this answer

With PSTricks. I show you how to put a point at any location: on the curve or not on the curve.

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\usepackage{pst-eucl}
\def\f(#1){x^2+0.5}

\begin{document}
\begin{pspicture}(-2.5,-0.5)(3,6)
    \psaxes[linecolor=gray,tickcolor=gray]{->}(0,0)(-2.5,-0.5)(2.5,5.5)[$x$,0][$y$,90]
    \psplot[algebraic]{-2.2}{2.2}{\f(x)}
    \pstGeonode[PosAngle={45,0}](0,1){F}(*1.1 {\f(x)}){A}
\end{pspicture}
\end{document}

or

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\usepackage{pst-eucl}
\usepackage{mathpazo}
\def\f(#1){x^2+0.5}

\begin{document}
\begin{pspicture}(-2.5,-0.5)(3,6)
    \psaxes[linecolor=gray,tickcolor=gray]{->}(0,0)(-2.5,-0.5)(2.5,5.5)[$x$,0][$y$,90]
    \psplot[algebraic]{-2.2}{2.2}{\f(x)}
    \pstGeonode[PosAngle=-30,PointNameSep=15pt,PointName={{\scriptstyle(0,0.5)},{\scriptstyle(1,f(1))}}]
            (0,0.5){F}(*1 {\f(x)}){A}
\end{pspicture}
\end{document}

Animation

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\usepackage{pst-eucl}
\usepackage{mathpazo}
\def\f(#1){x^2+0.5}

\def\Picture#1{%
\begin{pspicture}(-2.5,-0.5)(3,6)
    \psaxes[linecolor=gray,tickcolor=gray]{->}(0,0)(-2.5,-0.5)(2.5,5.5)[$x$,0][$y$,90]
    \psplot[algebraic]{-2.2}{2.2}{\f(x)}
    \pstGeonode[PosAngle={-15,135},PointNameSep=20pt,PointName={{\scriptscriptstyle(0.5,f(0.5))},{\scriptscriptstyle(#1,f(#1))}}]
            (*0.5 {\f(x)}){F}(*#1 {\f(x)}){A}
        \pstLineAB[nodesep=-1,linecolor=blue]{F}{A}
\end{pspicture}}

\begin{document}
\multido{\n=2.0+-0.1}{15}{\Picture{\n}}
\multido{\n=0.7+0.1}{13}{\Picture{\n}}
\end{document}

Warning!

The point (*1 {\f(x)}){A} uses the following weird "RPN-algebraic" syntax

(*<a constant numerical value in RPN expression> {<symbolic algebraic expression in x>})

No "algebraic-algebraic" syntax such as

({<a constant numerical algebraic expression>}| {<symbolic algebraic expression in x>})

is available.

share|improve this answer
    
I did not show you the tangent line at (0.5,f(0.5)) because it needs another trick! –  In PSTricks we trust Mar 24 '13 at 17:31

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.