1

I have two plots with different ranges. I want to draw them in a single plot, but if I do so the plots do not show the small fluctuations of each graph. I write:

\documentclass[tikz,border=0.5mm]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{width=10cm,compat=1.3}

\begin{document}

    \begin{tikzpicture}

    \begin{axis}[
    scale only axis,
    tick scale binop=\times,
    xtick={5, 10, 15, 20},
    xlabel={Number},
    ylabel={Rate (Gb/s)},
    legend style={at={(0.9,0.2)},
        anchor=east
    }]

    \addplot[dashdotted,color=red,mark=square*] coordinates {
        (5,  1.001)
        (10, 1.002)
        (15, 1.003)
        (20, 1.004)
    };
    \addplot[color=blue,mark=*,dashed] coordinates {
        (5,  2.001)
        (10, 2.002)
        (15, 2.003)
        (20, 2.004)
    };

    \addlegendentry{MVR T=1}
    \addlegendentry{MVR T=2}
    \end{axis}
    \end{tikzpicture}
\end{document}

and get the following result:

Bad Plot

But I want sth like this:

Desired

What should I do?

1
  • Have a look here.
    – user121799
    Jul 5, 2018 at 15:27

1 Answer 1

2

Using this answer, here's an option.

\documentclass[tikz,border=0.5mm]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}

\pgfplotsset{width=10cm,compat=1.16}

\begin{document}

\pgfplotsset{
% override style for non-boxed plots
    % which is the case for both sub-plots
    every non boxed x axis/.style={} 
}
\begin{tikzpicture}
\begin{groupplot}[
    group style={
        group name=my fancy plots,
        group size=1 by 2,
        xticklabels at=edge bottom,
        vertical sep=0pt,
    },
    yticklabel style={/pgf/number format/fixed,
              /pgf/number format/precision=3,
              /pgf/number format/zerofill},
    width=8.5cm,
    xmin=0, xmax=25
]
     \nextgroupplot[ymin=1.991,ymax=2.01,
    %scale only axis,
    axis y discontinuity=crunch,
    ytick={2.000, 2.005, 2.010},
    axis x line=top, 
    legend style={at={(0.9,0.9)},
    anchor=east
    }]
    \addplot[color=blue,mark=*,dashed] coordinates {
        (5,  2.001)
        (10, 2.002)
        (15, 2.003)
        (20, 2.004)
    };
    \addlegendentry{MVR T=2}
    \nextgroupplot[ymin=1,ymax=1.02,
    %scale only axis,
    tick scale binop=\times,
    ytick={1.000, 1.005, 1.010},
    xtick={5, 10, 15, 20},
    xlabel={Number},
    ylabel={Rate (Gb/s)},
    axis x line=bottom, 
    legend style={at={(0.9,0.4)},
        anchor=east
    }]

    \addplot[dashdotted,color=red,mark=square*] coordinates {
        (5,  1.001)
        (10, 1.002)
        (15, 1.003)
        (20, 1.004)
    };
    \addlegendentry{MVR T=1}

    \end{groupplot}
    \end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .