Graphics, Figures & TablesParallel Curves (2-6 parallel curves)

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jksp22
Posts: 7
Joined: Fri May 01, 2015 4:03 am

Parallel Curves (2-6 parallel curves)

Post by jksp22 »

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?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Parallel Curves (2-6 parallel curves)

Post by Johannes_B »

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.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10334
Joined: Mon Mar 10, 2008 9:44 pm

Parallel Curves (2-6 parallel curves)

Post by Stefan Kottwitz »

Well, add two labels separately. How? I could tell if you would show the drawing.

As Johannes said, post the existing drawing as Infominimal 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
LaTeX.org admin
jksp22
Posts: 7
Joined: Fri May 01, 2015 4:03 am

Parallel Curves (2-6 parallel curves)

Post by jksp22 »

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}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10334
Joined: Mon Mar 10, 2008 9:44 pm

Parallel Curves (2-6 parallel curves)

Post by Stefan Kottwitz »

Using shift is fine. Regarding efficiency, you can avoid repeating code and ensuring consistency by using
  • LaTeX macros (as usual),
  • TikZ styles,
  • \foreach loops for repeating things.
So, instead of writing ten times

Code: Select all

\draw[thick, color=..., domain=1:5] 
I recommend

Code: Select all

\draw[plot, color=...] 
where plot is your own style, for example defined as option to tikzpicture or globally via \tikzset:

Code: Select all

\begin{tikzpicture}[scale=0.9,
  plot/.style = {thick, domain=1:5}
]
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:

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 TikZ manual in 83 Repeating Things: The Foreach Statement. You can open it by typing texdoc tikz or texdoc pgf at the command prompt.

Stefan
LaTeX.org admin
Post Reply