You can use the undocumented save path
key that saves the whole path on a very low level in a macro. You can use this path again with the use path
key defined as
\makeatletter
\tikzset{use path/.code=\tikz@addmode{\pgfsyssoftpath@setcurrentpath#1}}
\makeatother
Any path operators shouldn’t be used here.
If you want to save part of a path and want to use them later (maybe also only as a part), you can use the saveuse path
key from another answer of mine defined as
\tikzset{
saveuse path/.code 2 args={
\pgfkeysalso{#1/.estyle={insert path={#2}}}%
\global\expandafter\let\csname pgfk@\pgfkeyscurrentpath/.@cmd\expandafter\endcsname % not optimal as it is now global through out the document
\csname pgfk@\pgfkeyscurrentpath/.@cmd\endcsname
\pgfkeysalso{#1}%
}
}
The saveuse path
key saves a path as an insert path
key (and uses it also) which can be used later for the same path (as long as you don’t change the transformation matrix).
Code A
\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{intersections}
\makeatletter
\tikzset{use path/.code=\tikz@addmode{\pgfsyssoftpath@setcurrentpath#1}}
\makeatother
\begin{document}
\begin{tikzpicture}[yscale=3,xscale=3]
%Pre-Define Paths
\path[save path=\pathA,name path=D1] (0,1.8) -- (1.8,0);
\path[save path=\pathB,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] {Quantity};
\draw[->,thick] (0,0) -- (0,2) node[left] {Price};
%Initial Equilibrium
\fill[black] (EQ) circle (.5pt) node[right] {$EQ$};
\draw[blue][use path=\pathA];
\draw[red] [use path=\pathB];
\end{tikzpicture}
\end{document}
Code B
\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{intersections}
\tikzset{
saveuse path/.code 2 args={
\pgfkeysalso{#1/.estyle={insert path={#2}}}%
\global\expandafter\let\csname pgfk@\pgfkeyscurrentpath/.@cmd\expandafter\endcsname % not optimal as it is now global through out the document
\csname pgfk@\pgfkeyscurrentpath/.@cmd\endcsname
\pgfkeysalso{#1}%
}
}
\begin{document}
\begin{tikzpicture}[yscale=3,xscale=3]
%Pre-Define Paths
\path[name path=D1] [saveuse path={pathA}{(0,1.8) -- (1.8,0)}];
\path[name path=S1] [saveuse path={pathB}{(0,0) -- (1.8,1.8)}];
\path[name intersections={of=D1 and S1,by=EQ}];
%axis
\draw[->,thick] (0,0) -- (3,0) node[right] {Quantity};
\draw[->,thick] (0,0) -- (0,2) node[left] {Price};
%Initial Equilibrium
\fill[black] (EQ) circle (.5pt) node[right] {$EQ$};
\draw[blue][pathA];
\draw[red] [pathB];
\end{tikzpicture}
\end{document}