Is it possible to have one set of dashed lines fill the gap of another set?
The black is just barely sticks out from the purple. I would like the black to fill the gap in the purple.
\documentclass[tikz, convert = false, dvipsnames]{standalone}
\usepackage{mathtools}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.8}
%\usepackage[dvipsnames]{xcolor}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
samples = 500,
no marks,
xlabel = $\scriptstyle x$,
ylabel = $\scriptstyle y$,
axis lines = middle,
xmin = -5,
xmax = 5,
ymin = -5,
ymax = 5,
legend style = {
at = {(-.35, 1)},
anchor = north west}
]
\foreach \u/\col in {0/red, 1/blue}{
\expandafter\addplot\expandafter+\expandafter[\col, domain = 0:2*pi]
({(exp(\u) + exp(-\u)) / 2 * cos(deg(x))},
{(exp(\u) - exp(-\u)) / 2 * sin(deg(x))});
}
\foreach \v/\colo in {0/OliveGreen, {pi/4}/Yellow, {pi/2}/RedOrange,
{3*pi/4}/Black, {5*pi/4}/Purple, {3*pi/2}/White,
{7*pi/4}/Brown}{
\expandafter\addplot\expandafter+\expandafter[\colo, domain = -5:5]
({(exp(x) + exp(-x)) / 2 * cos(deg(\v))},
{(exp(x) - exp(-x)) / 2 * sin(deg(\v))});
}
\legend{$u = 0$\\ $u = 1$\\ $v = 0$\\ $v = \pi / 4$\\ $v = \pi / 2$\\
$v = 3\pi / 4$\\ $v = 5\pi / 4$\\ $v = 3\pi / 2$\\ $v = 7\pi / 4$\\};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
Using
dash pattern=on <length> off <length>
you can give a uniform pattern for the dashed lines (gaps and strokes of the same length given by<length>
); then all you have to do is to usedash phase=<length>
to shift the dashed pattern for one of the plots; here's an illustration using a simplified version of your code:And, of course, the simplest solution is to have one solid line and superimpose the dashed one:
Here, incorporating this last approach to (part of) the original
\foreach
(I usedorange
andPurple
sinceBlack
andPurple
don't produce enough contrast):And now using dahed for both paths, and changing the pattern and phase: