
我想這樣標記座標。例如,我想將文字「(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
是pgfplots
宏,不能在 a 中使用,tikzpicture
除非您不將其包含在 axis 環境中(您的 MWE 無法編譯)。
如果您想標記一些其他座標,可能的解決方案是:
\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)
ETC。