Assumed we have this Minimum Working Example (MWE) to display a dateplot
with two completely identical x axis
, but with different xtick
positions:
\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}%
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line* = top,
axis y line* = left,
date coordinates in = x,
xtick = {2018-11-15,2018-12-15,2019-01-15,2019-02-15,2019-03-15,2019-04-15,2019-05-15},
xticklabels = {Nov,Dec,Jan,Feb,March,Apr,May},
date ZERO = 2018-11-01;
xmin = 2018-11-01;
xmax = 2019-05-01;
]
\end{axis}
\begin{axis}[
axis x line* = bottom,
axis y line* = right,
date coordinates in = x,
xtick = {2018-11-01,2018-12-01,2019-01-01,2019-02-01,2019-03-01,2019-04-01,2019-05-01},
xticklabels = {Nov,Dec,Jan,Feb,March,Apr,May},
date ZERO = 2018-11-01;
xmin = 2018-11-01;
xmax = 2019-05-01;
]
\end{axis}%
\end{tikzpicture}
\end{document}
Screenshot of the result:
Description of the issue:
- Despite of setting all
xticks
manually withxtick = {2019-01-15,...}
, they falsely appear on the completely same position likexticks
at very different dates of the secondx axis
, e.g.xtick = {2019-01-01,...}
. - Furthermore, the month
Nov
is completely missing (thanks marmot!)
Question:
How can I align the xticks
precisely without failure shifts in x
direction? While the upper x axis
should display the mean days of the month (e.g. 2019-01-15
), the lower x axis
should display the start dates of the month (e.g. 2019-01-01
).
date ZERO = 2018-11-01 00:00:00;
(should bedate ZERO = 2018-11-01 00:00:00,
),xmin
andxmax
. – user121799 May 10 at 15:37