2

I use the following code to draw from node (x2), which is located at (4,3), in one direction, return to it and then draw in another direction.

Is there a way to avoid returning to the node, for example saying: draw from node (x2) with xshift 4cm, then draw from node (x2) with yshift 3cm.

\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}

enter image description here

Hany
  • 4,709

2 Answers2

4

You don't need to return to it, just do two different \draws:

\draw [thick, black, dotted] 
    (x2.center) -- +(180:4.)
    (x2.center) -- +(-90:3);

or

\draw [thick, black, dotted] 
    ([shift={(180:4.)}]x2.center) -- (x2.center) -- +(-90:3);
Peter Grill
  • 223,288
3

i would use one of among solutions which have been provided to yours previous very similar (the same) questions:

\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}

enter image description here

Zarko
  • 296,517