
次のコードでは、点 (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}