So I have a quick noob question.
Using tikz, I'm trying to draw two parallel curves and for my purposes - double distance="x"cm - seemed to work. However, I need two different labels for this and I'm not sure how to do this.
For example, if supply shifts right, I want two parallel curves (not lines) to label S1 and S2, but at the moment...I only get S1.
How do I go about this issue? There must be a better method?
Graphics, Figures & Tables ⇒ Parallel Curves (2-6 parallel curves)
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: Parallel Curves (2-6 parallel curves)
Hi,
you can increase the chance of an answer by providing a minimal working example with what you got so far. Adding some visual help, a screenshot, paint foo, a hand drawing, might also help. Right now, at least i don't know what exactly you are looking for.
you can increase the chance of an answer by providing a minimal working example with what you got so far. Adding some visual help, a screenshot, paint foo, a hand drawing, might also help. Right now, at least i don't know what exactly you are looking for.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Parallel Curves (2-6 parallel curves)
Well, add two labels separately. How? I could tell if you would show the drawing.
As Johannes said, post the existing drawing as
minimal working example, so we can se how we can help to implement it. And indeed, sometimes an image with a hand drawn label would explain the requirement better than many words. 
Stefan
As Johannes said, post the existing drawing as


Stefan
LaTeX.org admin
Parallel Curves (2-6 parallel curves)
Here's an example of a code I made. I went away from "double distance" to using "xshift" and "yshift" which seems to be providing what I'd like it to do. Based on this example, am I doing anything inefficiently? Please be patient with me, I just got started with latex a week ago.

Code: Select all
\noindent\hspace*{\fill}
\begin{tikzpicture}[scale=0.9]
\usetikzlibrary{calc} %all
% axis
\draw[->] (0,0) -- (6,0) node[right] {$Y$};
\draw[->] (0,0) -- (0,5.5) node[left] {$P$};
\draw[->] (8,0) -- (14,0) node[right] {$Y$};
\draw[->] (8,0) -- (8,5.5) node[left] {$P$};
\def\adone{\x,{(4/\x)}}
\def\easone{-\x+6,{(4/\x}}
\draw[thick, color=red, domain=1:5] plot(\adone) node[right] {AD\textsubscript{0}};
\draw[thick, color=red, domain=1:5, xshift=0.5cm, yshift=0.5cm] plot(\adone) node[right] {AD\textsubscript{1}};
\draw[thick, color=red, domain=1:5, xshift=1cm, yshift=1cm] plot(\adone) node[right] {AD\textsubscript{2}};
\draw[thick, color=blue, domain=1:5] plot(\easone);
\draw[thick, color=blue, domain=1:5, xshift=-0.5cm, yshift=0.5cm] plot(\easone);
\draw[thick, color=blue, domain=1:5, xshift=-1cm, yshift=1cm] plot(\easone);
\draw (4.9,4.1) node[right, color=blue] {EAS\textsubscript{0}};
\draw (4.4,4.6) node[right, color=blue] {EAS\textsubscript{1}};
\draw (3.9,5.1) node[right, color=blue] {EAS\textsubscript{2}};
\draw [dashed] (3.0,1.35) -- (0,1.35) node[left] {P\textsubscript{0}};
\draw [dashed] (3.0,2.1) -- (0,2.1) node[left] {P\textsubscript{1}};
\draw [dashed] (3.0,3.0) -- (0,3.0) node[left] {P\textsubscript{2}};
\draw[thick, color=black] (3.0,5) -- (3.0,0) node[below] {$\bar{Y}$*};
\draw[->, very thick] (3.1,2.2) -- (3.1,2.8);
\draw[->, very thick] (3.1,1.4) -- (3.1,2.0);
\def\adtwo{\x+8,{(4/\x)}}
\def\eastwo{-\x+14,{(4/\x}}
\draw[thick, color=red, domain=1:5] plot(\adtwo) node[right] {AD\textsubscript{0}};
\draw[thick, color=red, domain=1:5, xshift=0.5cm, yshift=0.5cm] plot(\adtwo) node[right] {AD\textsubscript{1}};
\draw[thick, color=blue, domain=1:5] plot(\eastwo);
\draw[thick, color=blue, domain=1:5, xshift=-0.5cm, yshift=0.5cm] plot(\eastwo);
\draw (12.9,4.1) node[right, color=blue] {EAS\textsubscript{0}};
\draw (12.4,4.6) node[right, color=blue] {EAS\textsubscript{1}};
\draw [dashed] (11,1.35) -- (8,1.35) node[left] {P\textsubscript{0}};
\draw [dashed] (11,2.1) -- (8,2.1) node[left] {P\textsubscript{1}};
\draw [dashed] (11,2.1) -- (11,0) node[below] {Y\textsubscript{0}};
\draw [dashed] (11.7,1.7) -- (11.7,0) node[below] {Y\textsubscript{1}};
\draw[->, very thick] (11.1,1.5) -- (11.55,1.8);
\draw[->, very thick] (11.7,1.9) -- (11.2,2.1);
\end{tikzpicture}
\hspace{\fill}
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Parallel Curves (2-6 parallel curves)
Using shift is fine. Regarding efficiency, you can avoid repeating code and ensuring consistency by using
I recommend
where plot is your own style, for example defined as option to tikzpicture or globally via
You can even combine styles or inherit. A big advantage: you can adjust the domain at this single style place, not for each 10 plots as before.
You can use loops like this:
TikZ manual in 83 Repeating Things: The Foreach Statement. You can open it by typing
Stefan
- LaTeX macros (as usual),
- TikZ styles,
-
\foreach
loops for repeating things.
Code: Select all
\draw[thick, color=..., domain=1:5]
Code: Select all
\draw[plot, color=...]
\tikzset
:Code: Select all
\begin{tikzpicture}[scale=0.9,
plot/.style = {thick, domain=1:5}
]
You can use loops like this:
Code: Select all
\foreach \i/\x/\y in {1/0cm/0cm, 2/0.5cm/0.5cm, 3/1cm/1cm} {
\draw [plot, color=red, xshift=\x, yshift=\y]
plot(\adone) node[right] {AD\textsubscript{\i}};}
\foreach \x/\y in {0cm/0cm, -0.5cm/0.5cm, -1cm/1cm} {
\draw [plot, color=blue, xshift=\x, yshift=\y]
plot(\easone);}
\foreach
is explained in the 
texdoc tikz
or texdoc pgf
at the command prompt.Stefan
LaTeX.org admin