# How to generate a figure with a small one insert in the bigger one

The picture is like this:

I hope to generate it by tikz. Thank you!

New Problem:

I'm trying to generate a more complex figure. But it has some bugs. I don't know why. The code is as follows:

\usepackage[pdftex]{graphicx}
\usepackage{amsmath,environ}
\usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{caption}
\usepackage{pgfplots}

\begin{document}

\begin{figure*}[!tp]
\begin{minipage}{.49\textwidth}
\begin{tikzpicture}[scale=0.5]
\begin{axis}[
xlabel style={align=center},
xlabel=$Expiration\ Time\ (s)$ \\(a),
ylabel style={align=center},
ylabel=$Reduced\ RTT\ Ratio\ (\%)$,
xmin=10, xmax=60,
ymin=75, ymax=95,
legend style={nodes=right},
legend pos= south east]
\end{axis}
\draw(0.1,0.1) node{
\begin{axis}[scale=0.2][
xlabel style={align=center},
xlabel=$Expiration\ Time\ (s)$ \\(b),
xlabel style={align=center},
ylabel=$Cache\ Hit\ Rate\ (\%)$,
xmin=10, xmax=60,
ymin=80, ymax=100,
legend style={nodes=right},
legend pos= south east]
\end{axis}};
\end{tikzpicture}
\caption{Effects of expiration time of cache entry in delegates \newline}
\label{figure 4}
\end{minipage}
\end{figure*}

\end{document}

Fig4delay10000.txt:
10  83.70616734
20  87.78888284
30  89.30183444
40  90.08903274
50  90.58099978
60  90.92872104
Fig4hit10000.txt:
10  90.98347396
20  95.0861077
30  96.60898943
40  97.3979899
50  97.89094057
60  98.23992643

• pgfplots would be preferable in this case. – Alenanno Aug 6 '16 at 9:40
• Welcome to TeX - LaTeX! pdfplots as mentioned by Alenanno is built on top of tikz and indeed is a good starting point. Have a look at the package and try yourself. When you get stuck you can then ask a question here about the specific problem you have. – Andrew Swann Aug 6 '16 at 9:54

One way:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=$x$,ylabel=$y$]