1

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:

Screenshot of the result


Description of the issue:

  • Despite of setting all xticks manually with xtick = {2019-01-15,...}, they falsely appear on the completely same position like xticks at very different dates of the second x 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).

  • @marmot: The very first time that even you don't understand confusing LaTeX-behavior? :-) – Dave May 10 at 15:29
  • I guess the issue is simply that you use semicolons instead of commas in date ZERO = 2018-11-01 00:00:00; (should be date ZERO = 2018-11-01 00:00:00,), xmin and xmax. – user121799 May 10 at 15:37
  • @marmot: Great idea! Unfortunately the values of both axis move simultaneously when replacing the semicolons with commas. – Dave May 10 at 15:41
  • Furthermore, the november is still missing. :-) – Dave May 10 at 15:41
  • I agree. So I think there should be no semicolons but the issue you describe is then still there. (will decouple now...) – user121799 May 10 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.