Nodeposition bei Verwendung von symbolic x coords

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: Nodeposition bei Verwendung von symbolic x coords

von MarkAnthony85 » Do 2. Mär 2017, 15:26

Danke für die Antwort. Funktioniert super.

von esdd » Do 2. Mär 2017, 13:45

Wenn Du bei der axis Umgebung die Option
clip=false
ergänzt, dann kannst Du beispielsweise das folgende verwenden:
\node[anchor=east] at ({axis cs:14,29}-|current axis.west) {$U_{\mathrm{SOLL}}$};
Ohne die oben genannte Option kannst Du an der gewünschten Stelle eine Koordinate definieren und den Node an dieser Koordinate außerhalb der axis, aber innerhalb der tikzpicture Umgebung einfügen:
\documentclass{article} 
\usepackage[utf8]{inputenc} 
\usepackage{pgfplots}% lädt auch tikz
\pgfplotsset{compat=newest} 
\usepgfplotslibrary{units} 
\begin{document} 
\begin{figure}\centering 

\begin{tikzpicture} 
     \pgfplotsset{ 
     legend cell align = left, 
     legend pos = north east, 
     symbolic x coords={14,18,21,25}, 
     xtick=data
     } 
\begin{axis}[ 
    ymajorgrids, 
    no markers, 
    enlargelimits=false, 
    axis on top,     
    ybar=4pt, 
     width=\linewidth, 
      height=9.5cm, 
      axis lines*=left, 
      xlabel={Stickout~\lbrack mm\rbrack}, 
      ylabel=$U \lbrack \mathrm{V} \rbrack$, 
    axis y discontinuity=crunch, 
    %xtick={14,18,21,25}, 
     ytickmin=30, 
     ytickmax=38, 
     ymin=28, 
     ymax=38, 
     bar width=18pt, 
     enlarge x limits=0.2, 
    nodes near coords, 
     every node near coord/.append style= 
     { 
     font=\normalsize, 
     fill=white, 
     anchor=south 
     }, 
     legend pos = north west
     ]     
     \begin{scope} % Hilfslinie 
     \draw[thick,dashed,black] ({rel axis cs:1,0}|-{axis cs:14,29}) -- ({rel axis cs:0,0}|-{axis cs:25,29}) node[anchor=east,left] at (axis cs:14,29) {$U_{\mathrm{SOLL}}$}; 
     \end{scope}
     \coordinate (y1) at ({axis cs:14,29}-|current axis.west);
     \addplot[style={fill=blue!50!cyan},error bars/.cd, y dir=both, y explicit] 
     coordinates { 
           (14,32.3) += (0,1.1) -= (0,1.1) 
        (18,33.4) += (0,1.1) -= (0,1.1) 
          (21,34.3) += (0,1.1) -= (0,1.1) 
         (25,35.0) += (0,1.1) -= (0,1.1)};\addlegendentry{Smart Connector} 
    \addplot[style={fill=red!85!magenta},error bars/.cd, y dir=both, y explicit] 
     coordinates { 
           (14,34.7) += (0,0.7) -= (0,0.7) 
        (18,35.7) += (0,0.6) -= (0,0.6) 
          (21,36.7) += (0,0.6) -= (0,0.6) 
         (25,37.4) += (0,0.6) -= (0,0.6)};\addlegendentry{HKS-WeldAnalyst} 
    \addplot[style={fill=green!50!olive},error bars/.cd, y dir=both, y explicit] 
     coordinates { 
           (14,30.8) += (0,0.7) -= (0,0.7) 
        (18,32.1) += (0,1.5) -= (0,1.5) 
          (21,33.2) += (0,2.4) -= (0,2.4) 
         (25,34.1) += (0,2.4) -= (0,2.4)};\addlegendentry{Fronius TPS 5000} 
\end{axis}
\node[anchor=east] at (y1) {$U_{\mathrm{SOLL}}$}; 
\end{tikzpicture} 
\end{figure} 
\end{document} 
Mit ein paar weiteren Anpassungen könnte man auch die Option extra y ticks dafür nutzen.

Nodeposition bei Verwendung von symbolic x coords

von MarkAnthony85 » Do 2. Mär 2017, 12:34

Ich erstelle gerade ein Balkendiagramm. Dabei versuche ich eine Beschriftung ganz Links oder ganz rechts an eine Hilfslinie zubekommen. Ich habe die X-Achse anstelle von Zahlen mit Symbolen versehen damit die Balken gleichmäßig verteilt sind. Ich weiß gerade nicht wie ich die Position bei einen solchen Koordinatensystem außerhalb angeben kann.
hier das Minimalbsp. dazu:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{tikz}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{units} 
\begin{document}
\begin{figure}\centering

\begin{tikzpicture}
    \pgfplotsset{
    legend cell align = left,
    legend pos = north east,
    symbolic x coords={14,18,21,25},
    xtick=data,
    }
\begin{axis}[
	ymajorgrids,
	no markers,
	enlargelimits=false,
	axis on top,    
	ybar=4pt,
 	width=\linewidth,
  	height=9.5cm,
  	axis lines*=left,
  	xlabel={Stickout~\lbrack mm\rbrack},
  	ylabel=$U \lbrack \mathrm{V} \rbrack$,
	axis y discontinuity=crunch,
	%xtick={14,18,21,25},
    ytickmin=30,
    ytickmax=38,
    ymin=28,
    ymax=38,
    bar width=18pt,
    enlarge x limits=0.2,
	nodes near coords,
    every node near coord/.append style=
    {
    font=\normalsize,
    fill=white,
    anchor=south
    }, 
    legend pos = north west
    ]    
    \begin{scope} % Hilfslinie
    \draw[thick,dashed,black] ({rel axis cs:1,0}|-{axis cs:14,29}) -- ({rel axis cs:0,0}|-{axis cs:25,29}) node[anchor=east,left] at (axis cs:14,29) {$U_{\mathrm{SOLL}}$};
    \end{scope}
    %\node[anchor=east] at (axis cs:14,29) {$U_{\mathrm{SOLL}}$};
    \addplot[style={fill=blue!50!cyan},error bars/.cd, y dir=both, y explicit]
    coordinates {
       	(14,32.3) += (0,1.1) -= (0,1.1)
    	(18,33.4) += (0,1.1) -= (0,1.1)
   		(21,34.3) += (0,1.1) -= (0,1.1)
        (25,35.0) += (0,1.1) -= (0,1.1)};\addlegendentry{Smart Connector}
	\addplot[style={fill=red!85!magenta},error bars/.cd, y dir=both, y explicit]
    coordinates {
       	(14,34.7) += (0,0.7) -= (0,0.7)
    	(18,35.7) += (0,0.6) -= (0,0.6)
   		(21,36.7) += (0,0.6) -= (0,0.6)
        (25,37.4) += (0,0.6) -= (0,0.6)};\addlegendentry{HKS-WeldAnalyst}
	\addplot[style={fill=green!50!olive},error bars/.cd, y dir=both, y explicit]
    coordinates {
       	(14,30.8) += (0,0.7) -= (0,0.7)
    	(18,32.1) += (0,1.5) -= (0,1.5)
   		(21,33.2) += (0,2.4) -= (0,2.4)
        (25,34.1) += (0,2.4) -= (0,2.4)};\addlegendentry{Fronius TPS 5000}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

Nach oben