Seite 1 von 1

Problem mit Säulendiagramm (Zentrierung und Style)

Verfasst: So 12. Jul 2020, 16:35
von Tigerino

Hallo! Bin recht neu in Latex und habe Probleme mit einem Diagramm von mir, die ich einfach nicht gelöst bekomme. Die Linien der Balken machen was sie wollen, am Ende sind sie sogar nur gestrichelt. Des Weiteren erscheint überall dieser komische Punkt am oberen Ende eines jeden Balken. Außerdem sollen alle Zahlen im DIagramm diesseble Farbe haben. Wie kann ich das alles abändern? Danke!

Latex-Auszug:

\begin{tikzpicture}
\begin{axis}[bar width = 0.5cm, width = 13.3cm, height = 15cm, enlarge y limits = 0.05, ylabel = {Prozentsatz der Abdeckung}, x tick label style={rotate=45,anchor=east}, ymin = 0, ymax = 100, symbolic x coords = {AuD, BS, DuR, DLA, FuA, IaD, IuG, MDL, PuM, SWE}, xtick = {AuD, BS, DuR, DLA, FuA, IaD, IuG, MDL, PuM, SWE}]
\addplot+ [ybar, fill = red, draw=black, nodes near coords, semithick] coordinates{(AuD,60)};
\addplot+ [ybar, fill = blue, draw=black, nodes near coords, semithick] coordinates{(BS,3)};
\addplot+ [ybar, fill = yellow, draw=black, nodes near coords, semithick] coordinates{(DuR,80)};
\addplot+ [ybar, fill = green, draw=black, nodes near coords, semithick] coordinates{(DLA,5)};
\addplot+ [ybar, fill = purple, draw=black, nodes near coords, semithick] coordinates{(FuA,7)};
\addplot+ [ybar, fill = cyan, draw=black, nodes near coords, semithick] coordinates{(IaD,5)};
\addplot+ [ybar, fill = orange, draw=black, nodes near coords, semithick] coordinates{(IuG,9)};
\addplot+ [ybar, fill = lightgray, draw=black, nodes near coords, semithick] coordinates{(MDL,12)};
\addplot+ [ybar, fill = white, draw=black, nodes near coords, semithick] coordinates{(PuM,90)};
\addplot+ [ybar, fill = magenta, draw=black, nodes near coords, semithick] coordinates{(SWE,13)};
\end{axis}
\label{fig:prozent}
\end{tikzpicture}
\captionof{figure}{Prozentsatz der Abdeckung der Kompetenzen der Inhaltsbereiche im Basiscurriculum}

Das Diagramm ist als Grafik angehängt.


Re: Problem mit Säulendiagramm (Zentrierung und Style)

Verfasst: So 12. Jul 2020, 17:15
von Bartman

Liefere bitte ein vollständiges Beispiel und verwende dafür den geeigneten BBCode.

Setze erst den \caption-Befehl Deiner Wahl und danach den \label-Befehl.

Wie wäre es damit?

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}

\pgfplotsset{compat=1.17}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    bar width = 0.5cm, 
    width = 13.3cm, 
    height = 15cm,
    ylabel = {Prozentsatz der Abdeckung}, 
    x tick label style={rotate=45,anchor=north east},
    ymin=0,
    ymax = 100, 
    symbolic x coords = {AuD, BS, DuR, DLA, FuA, IaD, IuG, MDL, PuM, SWE}, 
    xtick = {AuD, BS, DuR, DLA, FuA, IaD, IuG, MDL, PuM, SWE},
    nodes near coords, 
    every axis plot/.append style={
        semithick,
        ybar
    }
]
\addplot [fill = red] coordinates{(AuD,60)};
\addplot [fill = blue] coordinates{(BS,3)};
\addplot [fill = yellow] coordinates{(DuR,80)};
\addplot [fill = green] coordinates{(DLA,5)};
\addplot [fill = purple] coordinates{(FuA,7)};
\addplot [fill = cyan] coordinates{(IaD,5)};
\addplot [fill = orange] coordinates{(IuG,9)};
\addplot [fill = lightgray] coordinates{(MDL,12)};
\addplot [fill = white] coordinates{(PuM,90)};
\addplot [fill = magenta] coordinates{(SWE,13)};
\end{axis}
\end{tikzpicture}
\end{document}

Re: Problem mit Säulendiagramm (Zentrierung und Style)

Verfasst: So 12. Jul 2020, 17:54
von Tigerino

Vielen Dank! Es funktioniert, ich weiss nur nicht genau warum :D


Re: Problem mit Säulendiagramm (Zentrierung und Style)

Verfasst: So 12. Jul 2020, 18:03
von Bartman

In der Dokumentation von pgfplots wird der Unterschied zwischen \addplot und \addplot+ erklärt.