Shift mark to bar position

Tabellen und Grafiken erstellen und anordnen


Vaschan
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 68
Registriert: So 8. Mai 2016, 12:35

Shift mark to bar position

Beitrag von Vaschan »

Hallo zusammen,

ist es möglich die marks auch über die Säulen zu schieben? Bei mir sind diese leider alle mittig über dem Tik.
\documentclass{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{figure}[htb]
	\centering
	\begin{tikzpicture}[farbe/.style={draw=#1,fill=#1}]
	\pgfkeyssetvalue{/mykeys/bardistance}{10pt}
	\begin{axis}[
	axis y line*=left,
	yticklabel pos=left,
	width=0.90\textwidth,
	height=0.45\textheight,
	xtick = {1,...,3},
	xticklabels={a,b,c},
	x tick label style={rotate=0},
	enlarge x limits=0.2,
	minor tick num=0,
	ymajorgrids,
	ybar,
	bar shift=0pt,
	ymin=0,ymax=1000, 
	xtick=data
	]
	
	\addplot+[bar shift=-3 mm, mark=otimes*] plot[error bars/.cd, y dir=both,y explicit] coordinates {
		(1,350) +- (4.6,4.6)
		(2,360) +- (9.5,9.5)
		(3,400) +- (7.5,7.5) };
	\end{axis}
	
	\begin{axis}[
	width=0.90\textwidth,
	height=0.45\textheight,
	axis y line*=right,
	yticklabel pos=right,
	xtick = {1,...,3},
	xticklabels={a,b,c},
	enlarge x limits=0.2,
	ybar,
	bar shift=10pt,
	ymin=0, ymax=25,
	axis x line=none
	]   
	\addplot+[bar shift=+3mm, mark=diamond] plot[error bars/.cd, y dir=both,y explicit] coordinates {
		(1,13.3) +- (0.2,0.2)
		(2,14.8) +- (0.1,0.1)
		(3,13.2) +- (0.2,0.2) };	

	\end{axis}
	\end{tikzpicture}
	\caption{test}
\end{figure}

\end{document}

Gast

Beitrag von Gast »

Meinst du so etwas wie
   \addplot+[mark=otimes*,every mark/.append style={xshift=-3mm,yshift=3mm}] plot[error bars/.cd, y dir=both,y explicit] coordinates {
      (1,350) +- (4.6,4.6)
      (2,360) +- (9.5,9.5)
      (3,400) +- (7.5,7.5) };
Also beispielsweise:
\documentclass{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{figure}[htb]
   \centering
   \begin{tikzpicture}[farbe/.style={draw=#1,fill=#1}]
   \begin{axis}[
   axis y line*=left,
   yticklabel pos=left,
   width=0.90\textwidth,
   height=0.45\textheight,
   xtick = {1,...,3},
   xticklabels={a,b,c},
   x tick label style={rotate=0},
   enlarge x limits=0.2,
   minor tick num=0,
   ymajorgrids,
   ybar=3mm,
   ymin=0,ymax=1000, 
   xtick=data
   ]
   
   \addplot+[mark=otimes*,every mark/.append style={xshift=-3mm,yshift=3mm}] plot[error bars/.cd, y dir=both,y explicit] coordinates {
      (1,350) +- (4.6,4.6)
      (2,360) +- (9.5,9.5)
      (3,400) +- (7.5,7.5) };
   \addplot+ coordinates {};
   \end{axis}
   
   \begin{axis}[
   width=0.90\textwidth,
   height=0.45\textheight,
   axis y line*=right,
   yticklabel pos=right,
   xtick = {1,...,3},
   xticklabels={a,b,c},
   enlarge x limits=0.2,
   ybar=3mm,
   ymin=0, ymax=25,
   axis x line=none
   ]   
   \addplot+ coordinates {};
   \addplot+[mark=diamond,every mark/.append style={xshift=3mm,yshift=3mm}] plot[error bars/.cd, y dir=both,y explicit] coordinates {
      (1,13.3) +- (0.2,0.2)
      (2,14.8) +- (0.1,0.1)
      (3,13.2) +- (0.2,0.2) };   

   \end{axis}
   \end{tikzpicture}
   \caption{test}
\end{figure}

\end{document}

Vaschan
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 68
Registriert: So 8. Mai 2016, 12:35

Beitrag von Vaschan »

Vielen Dank, genau das meine ich.
Gibt es dabei auch die Möglichkeit, dass die Marks sich automatisch an der Säulen x-Position orientieren?

Antworten