1

I have this .tex

\documentclass[12pt,margin=2mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\pgfplotsset{compat=1.16}
\usepackage{filecontents}
\begin{filecontents}{amm.csv}
year,aabach,grosseaa,emme
1975,,,438
1976,,,1943
1977,,,347
1978,,,208
1979,,,150
1980,,,238
1981,,,120
1982,,,198
1983,80,,167
1984,68,,158
1985,180,375,169
1986,140,407,119
1987,66,0,126
1988,,,60
1989,50,75,100
1990,,245,108
1991,,120,70
1992,,172,89
1993,,118,109
1994,,90,89
1995,43,122,164
1996,70,115,88
1997,50,70,40
1998,20,95,48
1999,152,152,86
2000,62,100,70
2001,35,110,40
2002,70,54,30
2003,35,66,39
2004,74,85,58
2005,65,92,50
2006,65,92,56
2007,36,60,10
2008,44,50,20
2009,45,100,57
2010,30,70,39
2011,30,35,40
2012,20,88,19
2013,24,34,29
2014,30,58,19
2015,25,30,48
2016,40,40,20
2017,26,50,30
\end{filecontents}

\begin{document}
\pgfkeys{/pgf/number format/.cd,1000 sep={}}
\begin{tikzpicture}
\begin{axis}[skip coords between index={1}{2},
ymin=0, ymax=500,
ytick={0,50,100,...,500},
xmin=1970,xmax=2018,
xtick={1975,1980,...,2020},
xlabel={Jahr},
ylabel={Konzentration [mg\,/\,$m^3$]},
width=15cm,
cycle list name=color
]
\addplot table [x=year, y=aabach, col sep=comma] {amm.csv};
\addplot table [x=year, y=grosseaa, col sep=comma] {amm.csv};
\addplot table [x=year, y=emme, col sep=comma, mark=*] {amm.csv};

\newcommand*{\VerticalPos}{70}% Desired vertical postion
    \coordinate (Left)  at ($(current axis.left of origin) +(axis direction cs: 0,\VerticalPos)$);
    \coordinate (Right) at ($(current axis.right of origin)+(axis direction cs: 0,\VerticalPos)$);
    \draw [ultra thick, dotted, draw=red] 
        (Left) -- (Right)
        node[pos=0.5,above,xshift=-140] {Grenzwert = \VerticalPos};
\legend{Aabach,Grosse Aa,Kleine Emme}        
\end{axis}
\end{tikzpicture}
\end{document}

which produces this pgfplot. Roughly after 2005, the data starts compressing and makes it difficult to read. Since there is a lot of space above 250, I was wondering if it's possible to "extend" the y-axis, but keep ymax=500? I.e. to fit more data between 0 and 250, without changing the height.

  • 1
    Welcome to TeX-SE! Maybe something like this is a possibility? – marmot Apr 23 at 4:42
  • Thank you! I used that answer and adapted the code to: \coordinate (spypoint) at (axis cs:2012.5,45); \coordinate (spyviewer) at (axis cs:2002.5,390); \spy[width=10cm,height=3cm] on (spypoint) in node [fill=white] at (spyviewer); – Max R Apr 23 at 7:22

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.