在下图中,我希望将包含标签“P”的节点放置在灰色线段的另一个端点。为什么“P”被排版在原点?
\documentclass[10pt]{amsart}
\usepackage{mathtools,array}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{center}
\begin{tikzpicture}
%Part of an ellipse and a parabola are drawn.
\draw (0,0) arc (0:90: 2 and 1);
\draw (0,0) arc (0:-72: 2 and 1);
\path node[anchor=east] at ({-2+sqrt(31)/8},-15/16){$E_{1}$};
\draw[fill] (0,0) circle (1.5pt);
%A "pin" is drawn between (0,0) and its label.
\draw[draw=gray, line width=0.8pt, shorten <=1.5mm, shorten >=0mm] (0,0) -- ({(atan(1/3)+90)/2}:0.75);
\path node[anchor=south] ({(atan(1/3)+90)/2}:0.75){$P$};
%
\draw[domain=-1:4, smooth, variable=\x, blue] plot ({\x}, {-1/9*\x*\x + 1/3*\x});
\path node[anchor=south west, xshift=-0.5mm, yshift=-1mm] at (3.75,-5/16){$E_{2}$};
\end{tikzpicture}
\end{center}
\end{document}
答案1
你遗漏了at
:
\路径节点[锚点=南]在({(atan(1/3)+90)/2}:0.75) {$P$};
您刚刚命名了该节点{(atan(1/3)+90)/2}:0.75
。
不过,由于您已经有了到该坐标的路径,因此您只需在那里添加节点即可:
\draw[draw=gray, line width=0.8pt, shorten <=1.5mm, shorten >=0mm] (0,0)
-- ({(atan(1/3)+90)/2}:0.75) node[anchor=south] {$P$};
我擅自用arc
PGFkeys 支持的较新语法重写了您的图片,该语法允许您设置特定值,例如半径,外部arc[]
它将用于路径/范围/组中包含的所有圆弧。
我也用过parabola
路径操作它不仅可以让您指定弯曲,还可以指定其位置或抛物线的高度(有关更多信息,请参阅手册)。
TikZ 还具有pin
选项与坐标和标签一起使用,但它可能不够精确,这取决于角度的来源(atan(1/3)+90)/2
。
代码
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw ([shift=(left:2)] -72:2 and 1) node[left]{$E_1$}
arc [start angle=-72, end angle=90, x radius=2, y radius=1];
\draw[fill] (0,0) circle [radius=1.5pt];
\draw[draw=gray, line width=0.8pt, shorten <=1.5mm, shorten >=0mm] (0,0)
-- ({(atan(1/3)+90)/2}:0.75) node[anchor=south] {$P$};
\draw[blue] (-1, -1/9-1/3) parabola bend (1.5, -.25+.5) (4, -16/9+4/3) node[right] {$E_2$};
\end{tikzpicture}
\end{document}
答案2
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) arc[start angle=0, end angle=90, x radius=2, y radius=1];
\draw (0,0) arc[start angle=0, end angle=-72, x radius=2, y radius=1] node[left]{$E_{1}$};
\draw[blue] plot[domain=-1:4, smooth] ({\x}, {-1/9*\x*\x + 1/3*\x}) node[above]{$E_{2}$};
\fill (0,0) circle (1.5pt);
\draw[draw=gray, thick, shorten <=1.5mm] (0,0) -- (50:0.8) node[above right, inner sep=1pt]{$P$};
\end{tikzpicture}
\end{document}