Seite 1 von 1

Weiteren Balken einfügen Tikzpicture

Verfasst: Di 13. Dez 2016, 13:29
von Peterlin
Hallo,

ich habe eine Grafik erstellt, mit jeweils 2 Balken über einem symbolischem x Wert.

Nun möchte ich einen dritten Balken jeweils hinzufügen. Der Balken soll allerdings transparent sein und über dem zweiten Balken liegen.

Am Besten versteht man es wenn man sich das mal anschaut:
\documentclass[a4paper,12pt,twoside]{report} 

\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel} 
\usepackage{lmodern} 
\usepackage{tikz} 

\usepackage{pgfplots, pgfplotstable}

\begin{document}

 \begin{figure}[htb]
\begin{tikzpicture} 
\begin{axis}[ 
 height=7.4cm, 
 width=\linewidth, 
 enlargelimits=0.05, 
 enlarge x limits={abs=30pt}, 
 legend style={ 
 at={(0.85,0.90)}, 
 anchor=north, 
 legend columns=-1 
}, 
 ymin=0, 
 ymax=30, 
 x tick label style={/pgf/number format/1000 sep=}, 
 x tick label style={rotate=45,anchor=east}, 
 symbolic x coords={SD Links,SD Rechts,MD Links,MD Rechts,Fond,Fussraum,Defrost},  
 xtick={SD Links,SD Rechts,MD Links,MD Rechts,Fond,Fussraum,Defrost},  
 ylabel={Volumenstrom in \%}, 
 ybar, 
 bar width=16pt, 
 ytick={0,5,10,...,30}, 
 ymajorgrids, 
 %xminorgrids, 
 %minor x tick num=1, 
 %subtickwidth=0pt, 
 nodes near coords, 
 %nodes near coords style={font=\footnotesize},% in Version 1.12 noch nicht definiert 
 every node near coord/.append style={font=\footnotesize}, 
 point meta=explicit symbolic, 
] 
\addplot coordinates {        %%Messung
 (SD Links,16.83) 
 (SD Rechts,18.01) 
 (MD Links,20.08) 
 (MD Rechts,18.77) 
 (Fond,26.11) 
 (Fussraum,0)
 (Defrost,0)
}; 
\addplot coordinates {      %%Prozentual
 (SD Links,17.90346159) 
 (SD Rechts,17.9098709) 
 (MD Links,18.50677835) 
 (MD Rechts,17.30987056) 
 (Fond,28.37001861) 
 (Fussraum,0)
 (Defrost,0)
}; 
\legend{Messung, CFD} 
\end{axis}

\end{tikzpicture}
\caption{Prozentuale Luftverteilung an den Auslässen für Warmluftklappe 0 \% bezogen auf den Gesamtvolumenstrom}
\label{fig:Luftverteilung1}
\end{figure}
Ich möchte quasi für "SD Links" einen dritten Plot einfügen, der aber nicht als dritter Balken daneben erscheint, sondern über dem zweiten Balken transparent erscheint und ggf. hinausragt.

Wie macht man sowas?

VIelen Dank!

Verfasst: Di 13. Dez 2016, 14:55
von Bartman
 (MD Links,20.08)
Deaktiviere die Smilies in Deinem Beitrag oder füge ein Leerzeichen ein.
(MD Links,20.08 )
Außerdem ist Dein Beispiel unvollständig. Der \end-Befehl für die document-Umgebung fehlt.

Verfasst: Di 13. Dez 2016, 14:59
von Pertlin
Entschuldigung
\documentclass[a4paper,12pt,twoside]{report}

\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{lmodern}
\usepackage{tikz}

\usepackage{pgfplots, pgfplotstable}

\begin{document}

 \begin{figure}[htb]
\begin{tikzpicture}
\begin{axis}[
 height=7.4cm,
 width=\linewidth,
 enlargelimits=0.05,
 enlarge x limits={abs=30pt},
 legend style={
 at={(0.85,0.90)},
 anchor=north,
 legend columns=-1
},
 ymin=0,
 ymax=30,
 x tick label style={/pgf/number format/1000 sep=},
 x tick label style={rotate=45,anchor=east},
 symbolic x coords={SD Links,SD Rechts,MD Links,MD Rechts,Fond,Fussraum,Defrost},  
 xtick={SD Links,SD Rechts,MD Links,MD Rechts,Fond,Fussraum,Defrost},  
 ylabel={Volumenstrom in \%},
 ybar,
 bar width=16pt,
 ytick={0,5,10,...,30},
 ymajorgrids,
 %xminorgrids,
 %minor x tick num=1,
 %subtickwidth=0pt,
 nodes near coords,
 %nodes near coords style={font=\footnotesize},% in Version 1.12 noch nicht definiert
 every node near coord/.append style={font=\footnotesize},
 point meta=explicit symbolic,
]
\addplot coordinates {        %%Messung
 (SD Links,16.83)
 (SD Rechts,18.01)
 (MD Links,20.0Cool
 (MD Rechts,18.77)
 (Fond,26.11)
 (Fussraum,0)
 (Defrost,0)
};
\addplot coordinates {      %%Prozentual
 (SD Links,17.90346159)
 (SD Rechts,17.9098709)
 (MD Links,18.50677835)
 (MD Rechts,17.30987056)
 (Fond,28.37001861)
 (Fussraum,0)
 (Defrost,0)
};
\legend{Messung, CFD}
\end{axis}

\end{tikzpicture}
\caption{Prozentuale Luftverteilung an den Auslässen für Warmluftklappe 0 \% bezogen auf den Gesamtvolumenstrom}
\label{fig:Luftverteilung1}
\end{figure}

\end{document}


Verfasst: Di 13. Dez 2016, 16:09
von esdd
(MD Links,20.0Cool 
ist auch nicht besser ;-)

Hier ist ein Vorschlag, der vielleicht weiter hilft:
\documentclass[a4paper,12pt,twoside]{report} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel} 
\usepackage{lmodern} 

\usepackage{pgfplotstable}% lädt auch pgfplots,tikz,xcolor,graphicx,...
\pgfplotsset{compat=1.14}% wichtig, siehe http://texwelt.de/wissen/fragen/19163

\begin{document} 
\begin{figure}[htb]
\begin{tikzpicture}
\pgfplotsset{
    every linear axis/.style={
    height=7.4cm, 
    width=\linewidth, 
    %enlargelimits=0.05, 
    enlarge x limits={abs=30pt},
    enlarge y limits={.15,upper},
    ymin=0, 
    ymax=30,
    symbolic x coords={SD Links,SD Rechts,MD Links,MD Rechts,Fond,Fussraum,Defrost},
    ybar,
    bar width=16pt,
    ytick={0,5,10,...,30},
    % die folgenden Optionen werden im MWE gar nicht genutzt?
    %nodes near coords,
    %every node near coord/.append style={font=\footnotesize},
    %point meta=explicit symbolic,
    }
}
\begin{axis}[ 
    legend style={ 
        %at={(0.85,0.90)},
        %anchor=north, 
        legend columns=-1
    }, 
    x tick label style={
        /pgf/number format/1000 sep={},
        rotate=45,anchor=east
    },
    xtick={SD Links,SD Rechts,MD Links,MD Rechts,Fond,Fussraum,Defrost},
    ylabel={Volumenstrom in \%}, 
    ymajorgrids, 
] 
\addplot coordinates {        %%Messung 
  (SD Links,16.83) 
  (SD Rechts,18.01) 
  (MD Links,20.08) 
  (MD Rechts,18.77) 
  (Fond,26.11) 
  (Fussraum,0) 
  (Defrost,0) 
}; 
\addplot coordinates {      %%Prozentual 
  (SD Links,17.90346159) 
  (SD Rechts,17.9098709) 
  (MD Links,18.50677835) 
  (MD Rechts,17.30987056) 
  (Fond,28.37001861) 
  (Fussraum,0) 
  (Defrost,0) 
};
\addlegendimage{fill=green,opacity=.2}
\legend{Messung, CFD,3. Plot} 
\end{axis} 
\begin{axis}[axis lines=none] 
\addplot coordinates {}; 
\addplot+[fill=green,opacity=.2] coordinates {% dummy beispiel
  (SD Links,5) 
  (SD Rechts,10) 
  (MD Links,24) 
  (MD Rechts,8) 
  (Fond,24) 
  (Fussraum,8) 
  (Defrost,3) 
}; 
 \end{axis} 
\end{tikzpicture} 
\caption{Prozentuale Luftverteilung an den Auslässen für Warmluftklappe 0 \% bezogen auf den Gesamtvolumenstrom} 
\label{fig:Luftverteilung1} 
\end{figure} 

\end{document}