单个图中有两幅范围不同的图

单个图中有两幅范围不同的图

我有两个范围不同的图。我想将它们绘制在一个图中,但如果我这样做,这些图就不会显示每个图的微小波动。我写道:

\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}

并得到以下结果:

糟糕的情节

但我想要这样的东西:

期望

我应该怎么办?

答案1

使用这个答案,这是一个选项。

\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}

在此处输入图片描述

相关内容