我使用以下代码从位于 (4,3) 的节点 (x2) 向一个方向绘制,返回到该节点,然后向另一个方向绘制。
有没有办法避免返回到节点,例如说:用 xshift 4cm 从节点 (x2) 绘制,然后用 yshift 3cm 从节点 (x2) 绘制。
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\begin{tikzpicture}[scale=.9, transform shape]
\draw [thick,-latex](0,0) -- (7.6,0) node [black, xshift=.2cm, yshift=0cm] {};
\draw [thick,-latex](0,0) -- (0,7) node [black, xshift=0cm, yshift=.2cm] {};
\draw [very thick, blue] (4.,3.) node (x2){} node [xshift=.2cm, yshift=.2cm] {x2} +(-30:2.6cm) -- +(150:4.6cm);
\draw [thick, black, dotted] (x2.center) +(180:4.) -- (x2.center) -- +(-90:3);
\end{tikzpicture}
\end{frame}
\end{document}
答案1
您不需要返回它,只需执行两项不同的操作\draws
:
\draw [thick, black, dotted]
(x2.center) -- +(180:4.)
(x2.center) -- +(-90:3);
或者
\draw [thick, black, dotted]
([shift={(180:4.)}]x2.center) -- (x2.center) -- +(-90:3);
答案2
我将使用为您以前提出的非常相似(相同)的问题提供的解决方案之一:
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\begin{tikzpicture}[scale=.9, % transform shape is not needed here
]
\draw [thick,-latex](0,0) -- (7.6,0);% node [right] {} if needed, with empy node is superflouos
\draw [thick,-latex](0,0) -- (0,7); % node [above] {} if needed, with empy node is superflouos
\draw [very thick, blue] (0,5.3) -- +(-30:7.6cm); % with use some trigonometry i would calculate start of this line
\draw [thick, dotted] (0,3) -| (4,0) node[pos=0.5,above right] {x2};
\end{tikzpicture}
\end{frame}
\end{document}