Überarbeitungsverlauf[Zurück]
Klicke auf Einblenden/Ausblenden von Überarbeitungen 2
winzige Änderung: alt-Texte ergänzt (und Umlaute eingefügt)

02 Mai '17, 10:35

saputello's gravatar image

saputello
11.1k174365

Ein "Farbverlauf" laesst lässt sich am Besten durch eine `colormap` in `pgfplots` abbilden. Davon gibt es eine ganze Reihe, sie werden normalerweise fuer für surface plots oder andere, kontinuierlich gefaerbte gefärbte Plots verwendet. Man kann `colormap` fuer normale Linienplots auch verwenden -- allerdings muss man dafuer dafür die Farbe eine `colormap` in die jeweiligen Optionen des `\addplot` Befehls reinbekommen. Eine sinnvolle Methode dafuer dafür ist ein relativ junges Feature in `pgfplots`: `cycle list={[of colormap]}`, von der es eine Reihe von Varianten gibt (wie `samples of colormap={<anzahl> of <colormap name>}` oder `colors of colormap={0,10,50,100 of <colormap name>}` oder `indices of colormap={0,1,2,3,10 of <colormap name>}`). Angewandt auf Dein Beispiel koennte könnte das wie folgt aussehen (wobei ich alles ausser außer den eigentlichen Farbverlaeufen Farbverläufen ausgeblendet habe): \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.14} \begin{document} \begin{tikzpicture} \begin{axis}[% domain=-14:0, xmin=-14, xmax=0, ymin=2.5, ymax=4.2, scaled ticks=false, legend style={at={(1,0)},anchor=south east}, legend entries={100\%, 90\%, 70\%, 50\%, 30\%, 10\%}, legend image code/.code={ \fill [#1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm); }, cycle list={[samples of colormap={6 of viridis}]}, ] \addplot {0.0140*x + 4.18}; \addplot {0.0142*x + 4.01}; \addplot {0.0146*x + 3.9}; \addplot {0.0144*x + 3.7}; \addplot {0.014*x + 3.6}; \addplot {0.015*x + 3.4}; \end{axis} \end{tikzpicture} \end{document} ![alt text][1] Pgfplots ![Beispiel mit viridis colormap][1] `pgfplots` kommt mit einem ganzen Zoo von `colormaps`, von denen die oben genutzte `viridis` eine der default colormaps ist. Die Bibliothek `colorbrewer` kommt mit einer Reihe weiterer nuetzlicher nützlicher colormaps. Hier ist beispielsweise die `colormap/OrRd-6` aus dieser Bibliothek, wobei ich die Reihenfolge mit `indices of colormap` umgedreht habe: \usepgfplotslibrary{colorbrewer} .. \begin{axis}[... colormap/OrRd-6, cycle list={[indices of colormap={6,5,4,3,2,1 of OrRd-6}]}, ] ![alt text][2] ![Beispiel mit colormap/OrRd-6][2] [1]: http://texwelt.de/wissen/upfiles/P_12.png [2]: http://texwelt.de/wissen/upfiles/PP_2.png
Klicke auf Einblenden/Ausblenden von Überarbeitungen 1

01 Mai '17, 00:20

cfeuersaenger's gravatar image

cfeuersaenger
3.7k23

Ein "Farbverlauf" laesst sich am Besten durch eine `colormap` in `pgfplots` abbilden. Davon gibt es eine ganze Reihe, sie werden normalerweise fuer surface plots oder andere, kontinuierlich gefaerbte Plots verwendet. Man kann `colormap` fuer normale Linienplots auch verwenden -- allerdings muss man dafuer die Farbe eine `colormap` in die jeweiligen Optionen des `\addplot` Befehls reinbekommen. Eine sinnvolle Methode dafuer ist ein relativ junges Feature in `pgfplots`: `cycle list={[of colormap]}`, von der es eine Reihe von Varianten gibt (wie `samples of colormap={<anzahl> of <colormap name>}` oder `colors of colormap={0,10,50,100 of <colormap name>}` oder `indices of colormap={0,1,2,3,10 of <colormap name>}`). Angewandt auf Dein Beispiel koennte das wie folgt aussehen (wobei ich alles ausser den eigentlichen Farbverlaeufen ausgeblendet habe): \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.14} \begin{document} \begin{tikzpicture} \begin{axis}[% domain=-14:0, xmin=-14, xmax=0, ymin=2.5, ymax=4.2, scaled ticks=false, legend style={at={(1,0)},anchor=south east}, legend entries={100\%, 90\%, 70\%, 50\%, 30\%, 10\%}, legend image code/.code={ \fill [#1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm); }, cycle list={[samples of colormap={6 of viridis}]}, ] \addplot {0.0140*x + 4.18}; \addplot {0.0142*x + 4.01}; \addplot {0.0146*x + 3.9}; \addplot {0.0144*x + 3.7}; \addplot {0.014*x + 3.6}; \addplot {0.015*x + 3.4}; \end{axis} \end{tikzpicture} \end{document} ![alt text][1] Pgfplots kommt mit einem ganzen Zoo von `colormaps`, von denen die oben genutzte `viridis` eine der default colormaps ist. Die Bibliothek `colorbrewer` kommt mit einer Reihe weiterer nuetzlicher colormaps. Hier ist beispielsweise die `colormap/OrRd-6` aus dieser Bibliothek, wobei ich die Reihenfolge mit `indices of colormap` umgedreht habe: \usepgfplotslibrary{colorbrewer} .. \begin{axis}[... colormap/OrRd-6, cycle list={[indices of colormap={6,5,4,3,2,1 of OrRd-6}]}, ] ![alt text][2] [1]: http://texwelt.de/wissen/upfiles/P_12.png [2]: http://texwelt.de/wissen/upfiles/PP_2.png