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

07 Feb '18, 13:22

cis's gravatar image

cis
9.6k104461491

pgfplots: Annotationen an y-Achse aus Tabelle

1 2018 128 110 3 2017 110 94 2 2017 144 128 1 2017 205 208 3 2016 161 146 2 2016 172 167 Ich habe hier den Plot einer komplizierten Tabelle, bei der die verschiedenfarbigen Balken zu gleichen Monaten, aber zu verschiedenen Jahren gehören. Die Legende beschreibt dies zwar, es ist aber auf den ersten Blick ggf. etwas verwirrend. Wie könnte ich an die y-Achse noch die konkreten Monatsnamen (oder auch die Monatszahl, egal..) mit Jahreszahl schreiben, z.B. so wie im 2. Bild? *Möglichst zusäzlich zur normalen Achsennummerierung `1,2,...,12`.* Die zugehörigen Jahreszahlen stehen auch in der Tabelle. [![alt text][1]][2] [![alt text][3]][3] %\documentclass[]{article} \documentclass[border=5mm]{standalone} \usepackage{pgfplots, amsmath} \pgfplotsset{compat=1.13, %north west common/.style={postaction={pattern=north east lines}}, 2017AD/.style={common, pattern color=red!70, fill=red!40, draw=red}, 2018AD/.style={common, pattern color= blue!70, fill=blue!40, draw=blue}, }% \usetikzlibrary{patterns} \begin{document} \begin{tikzpicture}[scale=0.75] \begin{axis}[ xbar, enlarge x limits=0.35, % font=\footnotesize\sffamily, % ytick = data, y = 1cm, ymin=0.4, ymax=3.6, % %point meta=x, nodes near coords={\Mitglieder \ [\Fragen]}, every node near coord/.append style={xshift=0pt,font=\footnotesize},%anchor=east, visualization depends on={value \thisrowno{2} \as \Mitglieder}, visualization depends on={value \thisrowno{3} \as \Fragen}, % xlabel={Neue Mitglieder}, ylabel={Kalendermonat}, legend entries={02.2017-01.2018 ,02.2016-01.2017}, legend columns=2, legend style={anchor=south,legend pos= north west,yshift=1cm, draw=none } ] \addplot [2017AD] table[x index=2, y index=0] { 1 2018 128 110 3 2017 110 94 2 2017 144 128 }; \addplot [2018AD] table[x index=2, y index=0] { 1 2017 205 208 3 2016 161 146 2 2016 172 167 }; \end{axis} \end{tikzpicture} \end{document} [1]: http://texwelt.de/wissen/upfiles/55555555_105.png [2]: http://texwelt.de/wissen/upfiles/55555555_105.png [3]: http://texwelt.de/wissen/upfiles/999999999999999_1.jpg
Klicke auf Einblenden/Ausblenden von Überarbeitungen 2

07 Feb '18, 13:18

cis's gravatar image

cis
9.6k104461491

pgfplots: Annotationen an y-Achse aus Tabelle

1 2018 128 110 3 2017 110 94 2 2017 144 128 1 2017 205 208 3 2016 161 146 2 2016 172 167 Ich habe hier den Plot einer komplizierten Tabelle, bei der die verschiedenfarbigen Balken zu gleichen Monaten, aber zu verschiedenen Jahren gehören. Die Legende beschreibt dies zwar, es ist aber auf den ersten Blick ggf. etwas verwirrend. Wie könnte ich an die y-Achse noch die konkreten Monatsnamen (oder auch die Monatszahl, egal..) mit Jahreszahl schreiben, z.B. so wie im 2. Bild? Die zugehörigen Jahreszahlen stehen auch in der Tabelle. [![alt text][1]][2] [![alt text][3]][3] %\documentclass[]{article} \documentclass[border=5mm]{standalone} \usepackage{pgfplots, amsmath} \pgfplotsset{compat=1.13, %north west common/.style={postaction={pattern=north east lines}}, 2017AD/.style={common, pattern color=red!70, fill=red!40, draw=red}, 2018AD/.style={common, pattern color= blue!70, fill=blue!40, draw=blue}, }% \usetikzlibrary{patterns} \begin{document} \begin{tikzpicture}[scale=0.75] \begin{axis}[ xbar, enlarge x limits=0.35, % font=\footnotesize\sffamily, % ytick = data, y = 1cm, ymin=0.4, ymax=3.6, % %point meta=x, nodes near coords={ \pgfmathparse{int(\Mitglieder)}\pgfmathresult\ [\pgfmathparse{int(\Fragen)}\pgfmathresult] }, coords={\Mitglieder \ [\Fragen]}, every node near coord/.append style={xshift=0pt,font=\footnotesize},%anchor=east, %nodes near coords style={/pgf/number format/.cd,precision=1}, visualization depends on={\thisrowno{2} on={value \thisrowno{2} \as \Mitglieder}, visualization depends on={\thisrowno{3} on={value \thisrowno{3} \as \Fragen}, % xlabel={Neue Mitglieder}, ylabel={Kalendermonat}, legend entries={02.2017-01.2018 ,02.2016-01.2017}, legend columns=2, legend style={anchor=south,legend pos= north west,yshift=1cm, draw=none } ] \addplot [2017AD] table[x index=2, y index=0] { 1 2018 128 110 3 2017 110 94 2 2017 144 128 }; \addplot [2018AD] table[x index=2, y index=0] { 1 2017 205 208 3 2016 161 146 2 2016 172 167 }; \end{axis} \end{tikzpicture} \end{document} [1]: http://texwelt.de/wissen/upfiles/55555555_105.png [2]: http://texwelt.de/wissen/upfiles/55555555_105.png [3]: http://texwelt.de/wissen/upfiles/999999999999999_1.jpg
Klicke auf Einblenden/Ausblenden von Überarbeitungen 1

07 Feb '18, 13:13

cis's gravatar image

cis
9.6k104461491