我知道以下是我的一个基本误解(令人费解)。我只是想将几个命名点放入现有图表中。以下是摘录:
\documentclass{standalone}
\usepackage{tikz, pgfplots}
\usetikzlibrary{arrows}
%\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates{(0,0)}; %% as expected
\addplot coordinates{(0,5)}; %% as expected
\addplot coordinates{(1,7)}; %% as expected
%% all of the below draw at 0,0!
\node[label={T1}] at (0.8,0.8) {T5}; %% puts T1 at 0,0
\draw(0.3,0.3) circle (0.2); %% no effect
\node[label={270:{(0.6,1)}}, circle, fill, inner sep=0.1pt] at (0.6,0.6) {T4};
\node[draw] at (0.8,0.8) {T5};
\draw(0.8,0.8) circle (0.4);
\end{axis}
\end{tikzpicture}
\end{document}
一如既往,感谢您的帮助。这篇文章可能只有一行,但对其他人来说也很有用。
/iaw
答案1
您在后面的绘图中缺少密钥axis cs
(使用密钥制作的绘图draw
)。摘自手册第 4.17.1 节
pgfplots 提供了一个用于轴内的新坐标系,即“轴坐标系”,axis cs。[...] 它可用于在轴坐标处绘制任何 TikZ 图形
所以这个代码应该可以工作
\documentclass{standalone}
\usepackage{tikz, pgfplots}
\usetikzlibrary{arrows}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates{(0,0)}; %% as expected
\addplot coordinates{(0,5)}; %% as expected
\addplot coordinates{(1,7)}; %% as expected
%% all of the below should now work
\node[label={T1}] at (axis cs: 0.8,0.8) {T5}; %% puts T1 at 0,0
\draw(axis cs: 0.3,0.3) circle [radius=0.2]; %% has effect
\node[label={270:{(0.6,1)}}, circle, fill, inner sep=0.1pt] at (axis cs: 0.6,0.6) {T4};
\node[draw] at (axis cs: 0.8,0.8) {T5};
\draw( axis cs: 0.8,0.8) circle [radius=0.4];
\end{axis}
\end{tikzpicture}
\end{document}
上面的代码生成了这样的图像:
您可能还想使用以下方式指定轴的长度begin{axis}[xmin=0,xmax=10,ymin=0,ymax=3]