
座標にラベルを付けたいと思います。たとえば、座標点 (1,0) の横に「(1,0)」というテキストを配置したいと思います。ノードのドキュメントを見てきましたが、もっと良い方法はないでしょうか。参考までに、私が描いた図を以下に示します。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (8,8);
\draw (0,0) -- (8,8);
\draw (0,2) -- (6,8); % line from (0,1/4) to (3/4,1)
\draw[->] (0,0) -- (8.5,0) node[anchor=north west] {$v_1$};
\draw[->] (0,0) -- (0,8.5) node[anchor=south east] {$v_2$};
\fill[black!40!white] (0,2) -- (6,8) -- (0,8) -- cycle;
\addplot[mark=*] coordinates {(0,1)} node:{$(0,1)$}{};
\end{tikzpicture}
\end{document}
答え1
私の理解が正しければ、次のようなものを探していることになります:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (8,8);
\draw (0,0) -- (8,8);
\draw (0,2) -- (6,8); % line from (0,1/4) to (3/4,1)
\draw[->] (0,0) -- (8.5,0) node[anchor=north west] {$v_1$};
\draw[->] (0,0) -- (0,8.5) node[anchor=south east] {$v_2$};
\fill[black!40!white] (0,2) -- (6,8) -- (0,8) -- cycle;
\node[circle,inner sep=1pt,fill=red,label=left:{$(0,1)$}] at (0,1) {};% this replace your `addplot`
\end{tikzpicture}
\end{document}
注:はマクロaddplot
であり、 axis 環境に含めない限り、pgfplots
で使用することはできません(MWE をコンパイルできません)。tikzpicture
他の座標にラベルを付けたい場合、考えられる解決策は次のようになります。
\coordinate[label=left:{(0,2)}] (A) at (0,2);
\coordinate[label=above:{(6,8)}] (B) at (6,8);
\draw[fill=black!40!white] (A) -- (B) -| (A);
次のように置き換えることができます:
\draw (0,2) -- (6,8); % line from (0,1/4) to (3/4,1)
\fill[black!40!white] (0,2) -- (6,8) -- (0,8) -- cycle;
MWE で。別の方法としては、次のようになります。
\draw (0,2) node[left] {(0,1)} -- (6,8) node[above] {(6,8)}; % line from (0,1/4) to (3/4,1)
等