# How to fit x-axis and y-axis to show a domain?

I try to draw this spiral by Matlab

t=[0:0.001:4*pi];
x=(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi))).*cos(t);
y=(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi))).*sin(t);
plot(x,y);


but I want to show the domain between two curve. First curve from t=0 to 2*pi and the second curve from t=2*pi to 4*pi.

How can draw this spiral by Latex?

Thank you very match, but a want show a x-axis between -1.1 and -0.99 and at y-axis between -1.1 and -0.99 we can see the spiral converge to 1 and if at take arg from 0 to 6*\pi . we need to show the domain especially in quarter three and four. for example in this figer the domain G and H.

• As I understand your problem title of your question is misleading. You like to draw two function on the same domain, as I see. For this in LaTeX exist meny options, between them the most poverful are packages pgfplots and pstricks. For first one is worth to look in example gallery http://pgfplots.net/ and of course read manual for this packages. ON this basis try to construct "Minimal Working Example (MWE)". Otherwise, this question will treat as do-it-for-me. – Zarko Dec 31 '15 at 2:13
• – John Kormylo Dec 31 '15 at 2:44
• @htu, I saw some of your other posts, like spiral spring in tikz and realized just after my answer, that you are probably asking for a quite different graph. Maybe you could tell us a bit more about what you actually want to accomplish? To me, it is very unclear. (might be just my understandings of math) – Runar Dec 31 '15 at 4:12
• In my last comment, I linked to a post, but apparently the answer which I was referring to was just deleted (unless I made a mistake). – Runar Dec 31 '15 at 4:52
• What is the meaning of .* in the equations. It couldn't be the same as * – user2478 Jan 1 '16 at 17:19

You could use PGFPlots, which gives great, flexible graphs with relatively short code.

I couldn't really make sense of what you are doing here mathematically (double exp? must be above my mathematical apprehension), so this probably doesn't look right. You should be able to adjust this to your needs.

\documentclass{article}
\usepackage{tikz}
\usepackage[graphics, active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{1em}

\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.12}

\begin{document}
\begin{tikzpicture}
\newcommand{\varT}{pi*x}
\begin{axis}[
y label style={rotate=-90},
title=My title,
ylabel = $y-axis$,
xlabel = {t},
]
red,
domain=0:2,
samples=17,
]
{(1/2)*(exp(exp(-\varT))+exp(exp(-\varT-2*pi)))*cos(\varT)};
blue,
domain=2:4,
samples=17,
]
{(1/2)*(exp(exp(-\varT))+exp(exp(-\varT-2*pi)))*sin(\varT)};
\legend{$(\frac{1}{2})[\exp(\exp(-t))+\exp(\exp(-t-2\pi))]cos(t)$,
$(\frac{1}{2})[\exp(\exp(-t))+\exp(\exp(-t-2\pi))]sin(t)$}
\end{axis}
\end{tikzpicture}
\end{document}


• I correct written of functions exp to \exp, sin to \sin and cos to \cos. Accordingly I upload new picture, which consider those changes. If you not liked this, you just return your answer to original form. – Zarko Dec 31 '15 at 3:59

A short code with pst-plot:

\documentclass[x11names, border=3pt]{standalone}
\usepackage{auto-pst-pdf}
\usepackage{fp}
\FPeval{\FourPi}{4*\FPpi}

\begin{document}

\psset{ algebraic, arrowinset=0.2, arrowsize=3.5pt, arrowlength=1.5, linejoin=1,unit=6, dimen=inner}
\begin{pspicture*}(-1.8,-1.5)(3,1.5)
\psset{plotpoints=200,fillstyle=solid}
\parametricplot[linewidth=1.8pt, linecolor=IndianRed3, fillcolor=Thistle3!50!]{0}{TwoPi}{%
(EXP(EXP(-t)) +EXP(EXP(-t-2*Pi)) )*COS(t)/2 | (EXP(EXP(-t)) +EXP(EXP(-t-2*Pi)) )*SIN(t)/2}%
\parametricplot[linewidth=1.2pt, linecolor=RoyalBlue3!50, opacity=1]{TwoPi}{\FourPi}{%
(EXP(EXP(-t)) +EXP(EXP(-t-2*Pi)) )*COS(t)/2 | (EXP(EXP(-t)) +EXP(EXP(-t-2*Pi)) )*SIN(t)/2}%
\psaxes[arrows=->, linecolor=SlateGray3,]{->}(0,0)(-2,-1.3)(2.5,1.5)[$x$, -120][$y$, -140]
\uput[dl](0,0){$O$}
\end{pspicture*}

\end{document}


• Judging by the "answer" posted by the OP I think (s)he wants something else, though I cannot understand exactly what. – Torbjørn T. Dec 31 '15 at 14:04

Another PSTricks solution with stolen code from Bernard. Run it with xelatex:

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\def\fx{(e^(e^(-t))+e^(e^(-t-2*Pi)))*cos(t)/2}
\def\fy{(e^(e^(-t))+e^(e^(-t-2*Pi)))*sin(t)/2}
\begin{document}

\psset{algebraic,arrowscale=1.5,unit=6,plotpoints=200,fillstyle=solid}
\begin{pspicture}(-1.5,-1.5)(3,1.6)
\psparametricplot[linewidth=1.8pt,linecolor=red!60,fillcolor=red!20]%
{0}{TwoPi}[/e Euler def]{\fx | \fy}%
\psparametricplot[linewidth=1.2pt,linecolor=blue!60,fillcolor=blue!10]%
{TwoPi}{TwoPi dup add}[/e Euler def]{\fx | \fy}%
\psaxes[linecolor=black!25]{->}(0,0)(-1.3,-1.3)(2.25,1.5)[$x$, -120][$y$, -140]
\end{pspicture}

\end{document}


• Thanks to your code, I begin to understand how to insert Postscript code inside a pspicture code :o). Just one question: is it possible from within LaTeX to patch a .pro file (to define, say, FourPi and the like) as one can patch a LaTeX command/ environment with etoolbox? – Bernard Dec 31 '15 at 15:16
• Use \pstVerb{/FourPi Pi 4 mul def} – user2478 Dec 31 '15 at 16:49

# The whole circle

I don't know if this looks like what you expect, but here's how you could plot a parametric curve, and fill the region between them. Don't know if the filling is something you want though. Note that the trigonometric functions assume degrees by default, which is why I've used deg(t) in those.

\documentclass[border=4mm]{standalone}

\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.12}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title=My title,
ylabel = {$y$},
xlabel = {$x$},
]
domain=0:2*pi,
samples=100,
variable=t,
name path=A
]
(
{(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi)))*cos(deg(t))},
{(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi)))*sin(deg(t))}
);

thick,
domain=2*pi:4*pi,
samples=100,
variable=t,
name path=B
]
(
{(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi)))*cos(deg(t))},
{(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi)))*sin(deg(t))}
);

\addplot [blue,opacity=0.1] fill between[of=A and B];
\end{axis}
\end{tikzpicture}
\end{document}


# Show just some quadrants

If you want to show just parts of this, you could of course adjust the domain. Perhaps easier is to just set xmin, xmax, ymin and ymax to whatever you like. For example:

\documentclass[border=4mm]{standalone}

\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=10cm,
height=6cm,
title=My title,
ylabel = {$y$},
xlabel = {$x$},
xmin=-1.1,xmax=1.1,
ymin=-1.01,ymax=0,
]
red,
thick,
domain=0:2*pi,
samples=100,
variable=t,
]
(
{(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi)))*cos(deg(t))},
{(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi)))*sin(deg(t))}
);

blue,
thick,
domain=2*pi:4*pi,
samples=100,
variable=t,
]
(
{(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi)))*cos(deg(t))},
{(1/2)*(exp(exp(-t))+exp(exp(-t-2*pi)))*sin(deg(t))}
);

\end{axis}
\end{tikzpicture}
\end{document}


# Completely different route

If you want to demonstrate that it becomes a circle, perhaps you could plot the distance from the origin as a function of t instead:

\documentclass[border=4mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title=Distance from origin,
ylabel = {$r$},
xlabel = {$t$},
xticklabel={$\pgfmathprintnumber{\tick}\pi$},
]