Überarbeitungsverlauf[Zurück]
Klicke auf Einblenden/Ausblenden von Überarbeitungen 5

07 Mär '14, 21:31

esdd's gravatar image

esdd
17.8k304257

## Update ## Ab Version 1.10 von [`pgfplots][1]` [`pgfplots`][1] kann man dafür einfach die pgfplotslibrary `fillbetween` nutzen: \documentclass[margin=5pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \usepgfplotslibrary{ dateplot, fillbetween } \begin{document} \begin{tikzpicture} \begin{axis}[ date coordinates in=x, xmin=2012-01-01, xticklabel=\day.\month, ] \addplot [red] coordinates { (2012-01-01,-1)(2012-02-17,-0.7)(2012-02-27,-0.2)(2012-03-17,0) (2012-03-19,-0.3)(2012-04-7,0.4)(2012-04-20,0.3)}; % Füllung: \path[name path=T](rel axis cs:0,1)--(rel axis cs:1,1); % obere Achse \path[name path=B](rel axis cs:0,0)--(rel axis cs:1,0); % untere Achse \addplot[blue, opacity=0.1]% Fülleigenschaften fill between [% of=T and B,% zwischen oberer und unterer Achse soft clip={domain=2012-02-12:2012-03-17}% Einschränkung des Zeitraumes ]; \end{axis} \end{tikzpicture} \end{document} ![alt text][2] ---------- Ursprüngliche Antwort: `pgfplots` stellt verschiedene Koordinatensysteme zur Verfügung. Wenn man neben dem `axis cs` noch das `rel axis cs` verwendet, dann müssen `ymin` und `ymax` nicht vorgegeben werden. Im `rel axis cs` entspricht eine Einheit der Länge der entsprechenden Koordinatenachse, d.h. `(rel axis cs:0,0)` bezeichnet die Diagrammecke links unten und `(rel axis cs:1,1)` die Diagrammecke rechts oben. \documentclass[margin=5pt]{standalone} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{pgfplots} \usepgfplotslibrary{dateplot} \pgfplotsset{compat=1.9} \newcommand\abschnittfaerben[3][]{% \fill[#1] ({rel axis cs:0,0}-|{axis cs:#2,0}) rectangle ({rel axis cs:0,1}-|{axis cs:#3,0}); } \begin{document} \begin{tikzpicture} \begin{axis}[ date coordinates in=x, xmin=2012-01-01, xticklabel=\day.\month, ] % \abschnittfaerben[blue,fill opacity=0.1]{2012-02-12}{2012-03-17} % \addplot [red] coordinates { (2012-01-01,-1)(2012-02-17,-0.7)(2012-02-27,-0.2)(2012-03-17,0) (2012-03-19,-0.3)(2012-04-7,0.4)(2012-04-20,0.3)}; \end{axis} \end{tikzpicture} \end{document} [1]: http://www.ctan.org/pkg/pgfplots [2]: http://texwelt.de/wissen/upfiles/DiagrAbschn.PNG
Klicke auf Einblenden/Ausblenden von Überarbeitungen 4
Variante mit pgfplotslibrary fillbetween

07 Mär '14, 02:57

esdd's gravatar image

esdd
17.8k304257

## Update ## Ab Version 1.10 von [`pgfplots][1]` kann man dafür einfach die pgfplotslibrary `fillbetween` nutzen: \documentclass[margin=5pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \usepgfplotslibrary{ dateplot, fillbetween } \begin{document} \begin{tikzpicture} \begin{axis}[ date coordinates in=x, xmin=2012-01-01, xticklabel=\day.\month, ] \addplot [red] coordinates { (2012-01-01,-1)(2012-02-17,-0.7)(2012-02-27,-0.2)(2012-03-17,0) (2012-03-19,-0.3)(2012-04-7,0.4)(2012-04-20,0.3)}; % Füllung: \path[name path=T](rel axis cs:0,1)--(rel axis cs:1,1); % obere Achse \path[name path=B](rel axis cs:0,0)--(rel axis cs:1,0); % untere Achse \addplot[blue, opacity=0.1]% Fülleigenschaften fill between [% of=T and B,% zwischen oberer und unterer Achse soft clip={domain=2012-02-12:2012-03-17}% Einschränkung des Zeitraumes ]; \end{axis} \end{tikzpicture} \end{document} ![alt text][2] ---------- Ursprüngliche Antwort: `pgfplots` stellt verschiedene Koordinatensysteme zur Verfügung. Wenn man neben dem `axis cs` noch das `rel axis cs` verwendet, dann müssen `ymin` und `ymax` nicht vorgegeben werden. Im `rel axis cs` entspricht eine Einheit der Länge der entsprechenden Koordinatenachse, d.h. `(rel axis cs:0,0)` bezeichnet die Diagrammecke links unten und `(rel axis cs:1,1)` die Diagrammecke rechts oben. \documentclass[margin=5pt]{standalone} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{pgfplots} \usepgfplotslibrary{dateplot} \pgfplotsset{compat=1.9} \newcommand\abschnittfaerben[3][]{% \fill[#1] ({rel axis cs:0,0}-|{axis cs:#2,0}) rectangle ({rel axis cs:0,1}-|{axis cs:#3,0}); } \begin{document} \begin{tikzpicture} \begin{axis}[ date coordinates in=x, xmin=2012-01-01, xticklabel=\day.\month, ] % \abschnittfaerben[blue,fill opacity=0.1]{2012-02-12}{2012-03-17} % \addplot [red] coordinates { (2012-01-01,-1)(2012-02-17,-0.7)(2012-02-27,-0.2)(2012-03-17,0) (2012-03-19,-0.3)(2012-04-7,0.4)(2012-04-20,0.3)}; \end{axis} \end{tikzpicture} \end{document} ![alt text][1] [1]: http://www.ctan.org/pkg/pgfplots [2]: http://texwelt.de/wissen/upfiles/DiagrAbschn.PNG
Klicke auf Einblenden/Ausblenden von Überarbeitungen 3
Befehl fürs Einfärben eines Abschnittes definiert

03 Nov '13, 23:19

esdd's gravatar image

esdd
17.8k304257

Klicke auf Einblenden/Ausblenden von Überarbeitungen 2

01 Nov '13, 22:00

esdd's gravatar image

esdd
17.8k304257

Klicke auf Einblenden/Ausblenden von Überarbeitungen 1

01 Nov '13, 21:57

esdd's gravatar image

esdd
17.8k304257