Tuesday, 6 August 2013

"Stroke" a predefined path

"Stroke" a predefined path

I would like to use the name of a previous defined path to draw it later
on in my code. I have included an example below, where I define two paths,
"D1" and "S1", and then later on, draw these very sames paths. In the
example, I draw the paths, using essentially the same code, which is
redundant. Is there a way to recall the name of the path and draw a line
using the previously defined path?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[yscale=3,xscale=3]
%Pre-Define Paths
\path[name path=D1] (0,1.8) -- (1.8,0);
\path[name path=S1] (0,0) -- (1.8,1.8);
\path[name intersections={of=D1 and S1,by=EQ}];
%axis
\draw[->,thick] (0,0) -- (3,0) node[right,fontscale=0] {Quantity};
\draw[->,thick] (0,0) -- (0,2) node[left,fontscale=0] {Price};
%Initial Equilibrium
\fill[black] (EQ) circle (.5pt) node[right] {$EQ$};
\draw[blue] (0,1.8) -- (1.8,0);
\draw[red] (0,0) -- (1.8,1.8);
\end{tikzpicture}
\end{document}

No comments:

Post a Comment