0

For the following plot (with time axis) I would like to add a bold, red vertical line at index 2010-01-01.

enter image description here

But I always run into a Dimension too large error. How can I solve this issue?

Here is the code

\begin{tikzpicture}
\begin{axis}[
    max space between ticks=25pt,
    scale only axis=true,
    every axis plot/.append style={very thick},
    tick style={black, thick},
    ylabel={},
    ymax=700000,
    %ymin=0,
    grid=major,
    enlarge x limits = false,
    width=\textwidth,
    height=0.5\textwidth,
    xticklabel = {\year},
    x tick label style={align=center},
    date coordinates in=x,
    table/col sep=comma,
    date ZERO={1991-01-01},
    xmin={1991-01-01},
    xmax={2021-01-01},
    xtick={1992-01-01, 1994-01-01, 1996-01-01, 1998-01-01, 2000-01-01, 2002-01-01, 2004-01-01, 2006-01-01, 2008-01-01, 2010-01-01, 2012-01-01, 2014-01-01, 2016-01-01, 2018-01-01, 2020-01-01},
    xticklabels={1992, 1994, 1996, 1998, 2000, 2002, 2004, 2006, 2008, 2010, 2012, 2014, 2016, 2018, 2020}
]

\addplot[black] table[x={month}, y={commits}, col sep=comma] {commits.csv}; \addplot[red, dashed] table[x={month}, y={0}, col sep=comma] {commits_growth.csv};

%\draw [red, dashed] ({2010-01-01}, 0) -- ({2010-01-01}, 700000); % causes 'Dimension too large' error

\end{axis}

\end{tikzpicture}

  • We don't have your data files, so we can't test your example. Can you make an example that doesn't rely on those files, or supply a sample of the files, sufficient to reproduce the problem? As always, it's appreciated if you can make a minimal but complete example from \documentclass to \end{document}, so it can be tested without modifications. – Torbjørn T. Nov 01 '21 at 16:04
  • 1
    Do you have \pgfplotsset{compat=1.11} (or some higher version number) anywhere, by the way? – Torbjørn T. Nov 01 '21 at 16:11
  • I cannot reproduce the problem: With some dummy data, the document \documentclass{article}\usepackage{pgfplots}\pgfplotsset{compat=1.18}\usetikzlibrary{pgfplots.dateplot}\begin{document}... your code ... \end{document} compiles fine. – gernot Nov 01 '21 at 17:35
  • As hinted at above, I suspect this is essentially the same thing as https://tex.stackexchange.com/questions/532832/ If you don't have a compat setting of 1.11 or higher, coordinates for \draw etc. inside an axis environment are not assumed to be in the coordinate system of the axis. So 2010-01-01 is probably read as a normal numeric coordinate for the tikzpicture, not a date coordinate in the axis. Either add the mentioned compat setting, or use axis cs to explicitly use the axis coordinate system, e.g. (axis cs:{2010-01-01}, 0) instead of ({2010-01-01}, 0). – Torbjørn T. Nov 01 '21 at 22:47
  • Oh stupid me. Indeed, the compat solved everything. Sorry for bothering you all. @TorbjørnT. since you were the first one who pointed this our, I would gladly accept your answer. – Michael Dorner Nov 02 '21 at 05:32

0 Answers0