I'm trying to put together a pgfplot inside a pre-existing tikz picture. But somehow the axis I create with pfgplot has different units and I'm not sure how to make the two things fit.
The code is:
\documentclass[11pt]{amsart}
\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper} % ... or a4paper or a5paper or ...
%\geometry{landscape} % Activate for for rotated page geometry
%\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{epstopdf}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
\title{Brief Article}
\author{The Author}
%\date{} % Activate to display a given date or no date
\begin{document}
\maketitle
\begin{tikzpicture}[scale=1]
\draw [line width=0.05cm] (0,1) to [out=80,in=180] (1,1) to [out=0,in=180] (2.5,1.5) to [out=0,in=-100] (4,1);
\draw [line width=0.05cm] (0,3) to [out=25,in=150] (1.5,3.5) to [out=-30,in=120] (3,3) to [out=-50,in=-155] (4,3);
\draw [thin, ->] (-0.1,0) -- (4.5,0);
\draw [thin, ->] (0, -0.1) -- (0, 4.5);
\draw [thin] (4, -0.1) -- (4, 0.1);
\draw [line width=0.05cm, red] (1, 1) to [out=0, in=180] (1.5, 1.5);
\draw [line width=0.05cm, red] (2.5, 2.5) to [out=0, in=180] (3, 3);
\begin{axis}[samples=3000]
\addplot[very thick,red ]plot (\x, {\x*sin(1/abs(\x))});
\end{axis}
\end{tikzpicture}
\end{document}
I would like somehow for the graph of the function x sin(1/|x|) (properly scaled and shifted) to connect the between the two pre-existing red lines smoothly.
Any help would be greatly appreciated.
** EDIT **
Here is some improved code:
and the result:
\begin{tikzpicture}
\path [fill=lightgray] (0,1) to [out=80,in=180] (1,1) to [out=0,in=180] (2.5,1.5) to [out=0,in=-100] (4,1) to (4,0) to (0,0);
\draw [line width=0.05cm] (0,1) to [out=80,in=180] (1,1) to [out=0,in=180] (2.5,1.5) to [out=0,in=-100] (4,1);
\path [fill=lightgray] (0,3) to [out=25,in=150] (1.5,3.5) to [out=-30,in=120] (3,3) to [out=-50,in=-155] (4,3) to (4,4.3) to (0,4.3); \draw [line width=0.05cm] (0,3) to [out=25,in=150] (1.5,3.5) to [out=-30,in=120] (3,3) to [out=-50,in=-155] (4,3); \draw [thin, ->] (-0.1,0) -- (4.5,0);
\draw [thin, ->] (0, -0.1) -- (0, 4.5);
\draw [thin] (4, -0.1) -- (4, 0.1);
\node [below] at (4, -0.1) {$2\pi$};
\node [below] at (0, -0.1) {$0$};
\draw [dashed] (-0.1, 2) -- (4,2);
\draw [line width=0.05cm, red] (1, 1) to [out=0, in=180] (1.5,1.5);
\draw [line width=0.05cm, red] (2.5,2.5) to [out=0, in=180] (3, 3);
\begin{axis}[samples=9000,scale only axis,axis lines=none]
\addplot[very thick,red ]plot (\x, {0.1*(\x + 3)*sin((1/abs((\x + 3)))r)});
\end{axis}



\documentclass{...}and ending with\end{document}. – Apr 06 '15 at 20:33