0

I wanted to draw from a point to x and y axes using only one coordinate definition. From the very appreciated answers to this question and this question, I used the following code to achieve my goal. My original drawing has too many nodes and I was concerned about using too many names for the nodes. Then I tried the following code:

\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,0);
\draw [thick,-latex](0,0) -- (0,7.);
\draw [thick, black, dashdotted] (1,1) node (o){} (o.center-|0,0) -| (o.center|-0,0);
\draw [very thick, green] (5,5) node (o){} +(-30:1.cm) -- +(150:1.cm);
\draw [thick, blue, dashed] (o.center) (o.center-|0,0) -| (o.center|-0,0);
\draw [thick, red, dotted] (2,2) node (o){} (o.center-|0,0) -| (o.center|-0,0);
\draw [thick, violet, double] (3,3) node (o){} (o.center-|0,0) -| (o.center|-0,0);
\draw [thick, brown, solid] (4,4) node (o){} (o.center-|0,0) -| (o.center|-0,0);
\draw [thick, brown, dotted] (6,6) node{} coordinate (o) edge (o -| 0,0) edge(o |- 0,0);
\end{tikzpicture}
\end{frame}
\end{document}

I got the following result:

enter image description here

I understood that each node should have a unique name. My question is how come all the nodes/coordinate have the same name, and still each drawing originates from its inline node; and even when using a node with the same name defined in another \draw command?

Hany
  • 4,709
  • 6
    Every time you write (...,...) node (o), you updates the coordinate associated to o.center. On first line o.center=(1,1), on second o.center=(5,5), and it's not anymore (1,1). – Ignasi Aug 13 '18 at 11:43
  • 2
    to add some details, each command is executed from top to bottom, what is below is the last thing that is drawn and is on top of all previous drawing if we talk about layers; as in programming, the reallocation of values to a constant operates from the assignment to the lines that continue in the future. – J Leon V. Aug 13 '18 at 14:56

0 Answers0