
다음 코드에서는 점 (1,1)에 "P"라는 레이블을 지정하고 싶습니다. (흥미롭지 않다는 것은 압니다. 제가 그리고 싶은 그래프의 일부입니다.) \node[above right, outer sep=2pt] (1,1) {P};
이 작업을 수행할 코드가 있습니다. TikZ
라벨을 원산지 오른쪽 위쪽에 붙이는 것입니다.
TikZ가 (1,1)의 위와 오른쪽에 라벨을 배치하지 않는 이유는 무엇입니까?
데카르트 평면에 그리드를 배치했습니다. 를 사용하면 outer sep=2pt
그리드의 일부가 P라는 레이블로 가려질 것으로 예상했습니다. 그래프에서 문자 "P"가 눈에 띄기를 원하고 그리드 선의 일부가 가려지면 그렇게 될 것이라고 생각합니다.
\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}
답변1
를 사용하여 노드 뒤의 그리드 선을 가릴 수 있습니다 fill=white
. pin
점에서 레이블까지 선을 그리는 를 사용하는 경우에도 이 작업을 수행할 수 있습니다 . 또는 label
유사하지만 줄이 없는 옵션을 사용할 수도 있습니다 .
\documentclass[tikz,border=5pt]{standalone}
\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 [fill, draw, circle, minimum width=3pt, inner sep=0pt, pin={[fill=white, outer sep=2pt]135:P}] at (.5,1) {};
\node[above right=10pt of {(1,1)}, outer sep=2pt,fill=white] {P};
\end{tikzpicture}
\end{document}