Tikz: Balken im Balken

Tabellen und Grafiken erstellen und anordnen


MenschMax

Tikz: Balken im Balken

Beitrag von MenschMax »

Hallo liebes Forum,

wie schaffe ich es, einen Balken (transpartent, z.B. schraffiert) über einen anderen Balken an der gleichen x-Position zu legen? Er hat dann logischerweise einen anderen y-Wert.

Anbei mein bisheriger Plot:
\documentclass[parskip=full]{scrbook} 

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

\usepackage{pgfplots, pgfplotstable}

\begin{document}

  \begin{tikzpicture} 
\begin{axis}[ 
 height=8cm, 
 width=8cm, 
 enlarge x limits={abs=20pt}, 
 legend style={ 
 at={(0.5,-0.3)}, 
 anchor=north, 
 legend columns=-1 
}, 
 ymin=0, 
 ymax=50, 
 symbolic x coords={0,10,20,30,40,50,60,70,80,90,100},  
 xtick={0,20,40,60,80,100},   
 ylabel={Abweichung in \%}, 
 ybar, 
 bar width=10pt, 
 ytick={0,5,10,...,50}, 
 ymajorgrids, 
 nodes near coords, 
 every node near coord/.append style={font=\footnotesize}, 
 point meta=explicit symbolic, 
] 
\addplot coordinates { 
 (0,49.00910427) 
 (10,52.67114996) 
 (20,30.03869207) 
 (30,16.19717274) 
 (40,11.793614) 
 (50,5.455339473)
 (60,4.335891305)
 (70,1.67210052)
 (80,4.440822806)
 (90,7.724997609)
 (100,19.49464651)

}; 
\end{axis}
\end{tikzpicture} 
\end{document}
Danke und Grüße

esdd
Forum-Meister
Forum-Meister
Beiträge: 2561
Registriert: So 7. Feb 2010, 16:36

Beitrag von esdd »

Mir ist jetzt nicht unbedingt klar, was Du machen möchtest. Aber vielleicht geht das folgende in die richitge Richtung:
\documentclass[parskip=full]{scrbook} 
\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel} 
\usepackage{lmodern} 

\usepackage{pgfplots}% lädt auch tikz
\pgfplotsset{compat=1.13}% nach dem Laden von pgfplots unbedingt compat setzen!!
\usetikzlibrary{patterns}

\begin{document} 
\begin{tikzpicture}
\pgfplotsset{
  every linear axis/.append style={
  height=8cm, 
  width=8cm, 
  enlarge x limits={abs=20pt}, 
  ymin=0, 
  ymax=50, 
  symbolic x coords={0,10,20,30,40,50,60,70,80,90,100},
  xmin=0,
  xmax=100,
  ybar, 
  bar width=10pt,
  }
}
\begin{axis}[
  %legend style={
    %at={(0.5,-0.3)},
    %anchor=north, 
    %legend columns=-1
  %},
  xtick={0,20,40,60,80,100},
  ylabel={Abweichung in \%},
  ytick={0,5,10,...,50}, 
  ymajorgrids,
  %nodes near coords,
  %every node near coord/.append style={font=\footnotesize},
  %point meta=explicit symbolic,
] 
\addplot coordinates { 
  (0,49.00910427) 
  (10,52.67114996) 
  (20,30.03869207) 
  (30,16.19717274) 
  (40,11.793614) 
  (50,5.455339473) 
  (60,4.335891305) 
  (70,1.67210052) 
  (80,4.440822806) 
  (90,7.724997609) 
  (100,19.49464651) 
}; 
\end{axis} 
\begin{axis}[axis lines=none]
\addplot[red,pattern= north west lines,pattern color=red]
  coordinates {(60,3.5)}
; 
\end{axis} 
\end{tikzpicture} 
\end{document}

Antworten