How can I specify the x coordinates in the \draw and \node commands below using dates (e.g., 2019-03-28 instead of 5.2)? Thanks.
\documentclass{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{pgfplots.dateplot}
\pgfplotsset{height=0.7\textwidth,width=\textwidth,compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
date coordinates in = x,
date ZERO = 2019-01-01,
xmax = 2019-06-30,
xmin = 2019-01-01,
xtick = {2019-01-01, 2019-02-01, 2019-03-01,
2019-04-01, 2019-05-01, 2019-06-01},
xticklabels = {J, F, M, A, M, J},
ymax = 5,
ymin = 0,
]
\end{axis}
\draw[decorate,decoration={brace,amplitude=4pt,mirror},yshift=-16pt]
(0,0)--(5.2,0) node[black,midway,yshift=-10.5pt]{Q1};
\draw[decorate,decoration={brace,amplitude=4pt,mirror},yshift=-16pt]
(5.3,0)--(10.6,0) node[black,midway,yshift=-10.5pt]{Q2};
\node [below=31pt] at (5.25,0) {Date};
\end{tikzpicture}
\end{document}
0would cause PGF Math's "base 8" error discussed in the comments of here. To see it in action, one can try changing the date in theacoordinate to08. This bug doesn't occur if the coordinate is plotted through\addplot, which only adds to the head-scratching. – bongbang Apr 30 '22 at 09:52