2

I have a plot of a rational function. I use \addplots to plot one point on it. TikZ marks the point with a diamond. I want to mark it with a dot. How do I specify the options to make the dot the same color as blue or a different color? How do I specify the size? Is the default size for a dot 1.5pt?

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{axis}[width=6in,axis equal image,clip=false,
    axis lines=middle,
    xmin=-42.5,xmax=42.5,
    samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-42.5,ymax=42.5,
    restrict y to domain=-42.5:42.5,
    xtick={},ytick={},
    ticklabel style={font=\tiny,fill=white},
    enlargelimits={abs=0.25cm},
    axis line style={latex-latex},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot[samples=501,domain=-40:64/41,blue] {(x + 16)/(x - 2)};
\addplot[samples=501,domain=32/13:40,blue] {(x + 16)/(x - 2)} node[above,pos=0.9,font=\footnotesize]{$y=\frac{x+16}{x-2}$};

\addplot[dashed, latex-latex, samples=2, domain=-42.5:42.5] {1} node[above,pos=0.1,font=\footnotesize]{$y=1$};
\addplot [dashed, latex-latex, samples=2, domain=-42.5:42.5] (2,x) node [pos=0.1, anchor=north, font=\footnotesize, sloped] {$x=2$};

\addplot coordinates{(5,7)} node[anchor=west,font=\footnotesize]{$(5,7)$};
\end{axis}
\end{tikzpicture}

\end{document}
1

Add [mark=*,blue,mark size=2pt] to the plot coordinate, where mark=* makes a little ball, blue is the colour and mark size=2pt is the size.

Output

figure 1

Code

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{axis}[width=6in,axis equal image,clip=false,
    axis lines=middle,
    xmin=-42.5,xmax=42.5,
    samples=201,
    xlabel=$x$,ylabel=$y$,
    ymin=-42.5,ymax=42.5,
    restrict y to domain=-42.5:42.5,
    xtick={},ytick={},
    ticklabel style={font=\tiny,fill=white},
    enlargelimits={abs=0.25cm},
    axis line style={latex-latex},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot[samples=501,domain=-40:64/41,blue] {(x + 16)/(x - 2)};
\addplot[samples=501,domain=32/13:40,blue] {(x + 16)/(x - 2)} node[above,pos=0.9,font=\footnotesize]{$y=\frac{x+16}{x-2}$};

\addplot[dashed, latex-latex, samples=2, domain=-42.5:42.5] {1} node[above,pos=0.1,font=\footnotesize]{$y=1$};
\addplot [dashed, latex-latex, samples=2, domain=-42.5:42.5] (2,x) node [pos=0.1, anchor=north, font=\footnotesize, sloped] {$x=2$};

\addplot[mark=*,blue,mark size=2pt] coordinates{(5,7)} node[anchor=west,font=\footnotesize]{$(5,7)$};
\end{axis}
\end{tikzpicture}
\end{document}
  • Thanks for the reply. You tell me that mark=* instructs pgfplots to mark that point (5,7) with a dot. This seems like an odd "synonym." What is the option if I wanted to mark this point with a square or a triangle or a diamond? – user74973 Jun 9 '15 at 18:34
  • 1
    @user74973 See the pgfplots manual, 4.6.1 Markers, page 79. – Alenanno Jun 9 '15 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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