pgfplots 中带有日期坐标的组图内的颜色图

pgfplots 中带有日期坐标的组图内的颜色图

我在组图中使用具有 x 日期坐标的颜色图时遇到问题。

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepgfplotslibrary{dateplot}
\pgfplotsset{
    compat = 1.16,
    width = 8cm,
    height = 5cm,
}
\begin{document}
%
% Group plot with date coordinates in x
% Colormap does not work
%
\begin{tikzpicture}
\begin{groupplot}[
    colorbar, % This fails
    group style = {
        group size = 1 by 2,
    },
    date coordinates in = x,
]
\nextgroupplot
\addplot [mesh] coordinates {
    (2018-01-01, 1)
    (2018-02-01, 2)
    (2018-03-01, 3)
    (2018-04-01, 4)
    (2018-05-01, 5)
    (2018-06-01, 6)
};
\nextgroupplot
\addplot [mesh] coordinates {
    (2018-01-01, 1)
    (2018-02-01, 4)
    (2018-03-01, 9)
    (2018-04-01, 16)
    (2018-05-01, 25)
    (2018-06-01, 36)
};
\end{groupplot}
\end{tikzpicture}
%
% Group plot with numerical coordinates in x (no dates)
% Colormap works
%
\begin{tikzpicture}
\begin{groupplot}[
    colorbar,
    group style = {
        group size = 1 by 2,
    },
]
\nextgroupplot
\addplot [mesh] coordinates {
    (1, 1)
    (2, 2)
    (3, 3)
    (4, 4)
    (5, 5)
    (6, 6)
};
\nextgroupplot
\addplot [mesh] coordinates {
    (1, 1)
    (2, 4)
    (3, 9)
    (4, 16)
    (5, 25)
    (6, 36)
};
\end{groupplot}
\end{tikzpicture}
%
% Individual plots with date coordinates in x
% Colormap works
%
\begin{tikzpicture}
\begin{axis}[
    colorbar,
    date coordinates in = x,
]
\addplot [mesh] coordinates {
    (2018-01-01, 1)
    (2018-02-01, 2)
    (2018-03-01, 3)
    (2018-04-01, 4)
    (2018-05-01, 5)
    (2018-06-01, 6)
};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
    colorbar,
    date coordinates in = x,
]
\addplot [mesh] coordinates {
    (2018-01-01, 1)
    (2018-02-01, 4)
    (2018-03-01, 9)
    (2018-04-01, 16)
    (2018-05-01, 25)
    (2018-06-01, 36)
};
\end{axis}
\end{tikzpicture}
\end{document}

如果我制作两个单独的图(使用\begin{axis}...\end{axis}),则颜色图会按预期工作。如果我使用数字坐标(即没有日期)制作组图,则颜色图会按预期工作。如果我尝试同时使用两者,则会收到以下错误:

Runaway argument?
\pgfplots@calender@ZEROSHIFT \relax \ifx \pgfplotstemptime \pgfutil@empty \ETC.
! File ended while scanning use of \pgfcalendar@datetojulian.
<inserted text> 
                \par 
<*> a.tex

I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! Emergency stop.

我究竟做错了什么?

相关内容