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.

3
  • 1
    Welcome to TeX-SE! Maybe something like this is a possibility?
    – user121799
    Apr 23, 2019 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, 2019 at 7:22
  • Same as tex.stackexchange.com/q/359878? Oct 26, 2019 at 7:19

1 Answer 1

1

As a suggestion, you can use a semilog-plot:

  • it results in less crowded data points
  • it conveys an important message:
  • all 3 regions decay exponentially at almost the same rate.

The minor changes needed are indicated by % <<< :

semilog

\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{semilogyaxis}[                   % <<<
        title=Vergleichsdaten 1975 - 2017,  % <<<
        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{semilogyaxis}                      % <<<
 \end{tikzpicture}
\end{document}

P.S., just for insight

As an aside, this semilog-plot can open new perspectives wrt data and the information they do or do not convey.

With 1995/1.9700 as reference points and neglecting earlier data the 3 curves can be perceived as 3 linear graphs, with some variation/deviation, caused by various noise sources. Analysis of variance (ANOVA) on all data indicates:

  • 68.6 % variation of data caused be average gradient (which is kind of normal)
  • 6.6 % caused by the 3 locations/regions
  • 7.3 % caused by impact of noise on the 3 gradients of the 3 locations
  • 17.5 % residual (unresolved) error variation

anovaResults

So a resonable summary then would be:

  • to pool all errors
  • abandon individual gradients for the 3 locations/regions
  • replace them by just one global gradient (roughly the fat red line)
  • fit each data column to this average gradient AND obtain 3 abscissa values (initial amplitudes)
  • perceive these absissa values as characteristic values
  • relate them to other reasonable sources of variations, like width of river etc.
  • which all also do correspond to a certain time-delay from abscissa and gradient (exponential behaviour in linlin world)

From an insight-point-of-view these:

  • simplifies results
  • simplifies conclusions
  • avoids "chasing the wind"
  • helps focusing on what's important, like improving measurement, policies etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .