In the following code, I want to label the point (1,1) as "P." (It is not exciting, I know. It is part of a graph that I want to draw.) I have the code \node[above right, outer sep=2pt] (1,1) {P};
to do this. TikZ
is putting the label above and to the right of the origin.
Why isn't TikZ putting the label above and to the right of (1,1)?
I have a grid placed on the Cartesian plane. With outer sep=2pt
, I expected that some of the grid would be obscured by the label P. I want the letter "P" to stand out on the graph, and I think it would if some of the grid lines were obscured.
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,intersections,quotes}
\begin{document}
\begin{tikzpicture}
\draw[yellow] (-1.25,-1.25) grid[xstep=0.5, ystep=0.5] (2.25,2.25);
\draw[draw=gray!30,latex-latex] (0,2) +(0,0.5cm) node[above right] {$y$} -- (0,-1) -- +(0,-0.5cm);
\draw[draw=gray!30,latex-latex] (-1,0) +(-0.5cm,0) -- (2,0) -- +(0.5cm,0) node[below right] {$x$};
\filldraw (1,1) circle[radius=1.5pt];
\node[above right, outer sep=2pt] (1,1) {P};
\end{tikzpicture}
\end{document}
Best Answer
You can obscure the grid lines behind the node using
fill=white
. You can also do this if you use apin
which will draw a line from the point to the label. Or you could use thelabel
option which is similar but without the line.