组图中的重叠和无效填充

组图中的重叠和无效填充

我试图将多个图放在同一个图中。在每个图中,我希望突出显示某个区域。但是,这些图之间存在大量重叠,突出显示根本不起作用。以下是 MWE:

\documentclass[margin=5pt]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{
  dateplot,
  fillbetween,
  groupplots
}
\pgfkeys{/pgf/number format/.cd,fixed,
      use comma}

\begin{document}
\begin{tikzpicture}
  \begin{groupplot}[
    date coordinates in = x,
    xticklabel={\year},
    no marks,
    scaled y ticks = false,
    xtick = {1990-01-01, 1995-01-01, 2000-01-01, 2005-01-01,
      2010-01-01, 2015-01-01},
    group style = {group size = 2 by 1,
         horizontal sep =1cm,
         vertical sep = 1cm,
      %   xlabels at=edge bottom
       },
    ]
    \nextgroupplot
    \addplot[blue] coordinates {
      (1995-01-01,0.00419152827774827)
      (1995-11-28,-0.0034102121140176)
      (2002-08-22, 0.0076423873165794)
    };
    \addplot[orange] coordinates {
      (1995-01-01, 0.00082432847433811)
      (1995-11-28, -0.00109642468521187)
      (2002-08-22,0.0184758085974366)
    };
    \path[name path=T](rel axis cs:0,1)--(rel axis cs:1,1); % obere Achse
    \path[name path=B](rel axis cs:0,0)--(rel axis cs:1,0); % untere Achse
    \addplot[green, opacity=0.5] % Fülleigenschaften
      fill between [%
      of=T and B,% zwischen oberer und unterer Achse
      soft clip={domain=1995-01-01:2000-01-01}% Einschränkung des Zeitraumes
    ];
    \nextgroupplot
    \addplot[blue] coordinates {
      (1995-01-01, 0.0120056542276519)
      (1995-11-28, 0.00138251635145359)
      (2002-08-22, 0.00493968691707103)
    };
    \addplot[orange] coordinates {
      (1995-01-01, 0.00012103619804904)
      (1995-11-28, 0.00397950876242348)
      (2002-08-22, 0.0141901119999108)
    };
    \path[name path=T](rel axis cs:0,1)--(rel axis cs:1,1); % obere Achse
    \path[name path=B](rel axis cs:0,0)--(rel axis cs:1,0); % untere Achse
    \addplot[green, opacity=0.5] % Fülleigenschaften
      fill between [%
      of=T and B,% zwischen oberer und unterer Achse
      soft clip={domain=1995-01-01:2000-01-01}% Einschränkung des Zeitraumes
    ];
  \end{groupplot};
\end{tikzpicture}
\end{document}

结果是有问题的输出

答案1

添加

set layers,cell picture=true

添加到groupplot选项中即可修复此问题。这似乎是 pgfplots 1.12 中存在的错误的解决方法。

相关内容