Seite 1 von 1

Balkendiagramm mit Tikz

Verfasst: Di 29. Nov 2016, 16:24
von TK1985
Hallo zusammen,

ich habe aus Matlab heraus ein Balkendiagram, das Mittelwerte und zugehörige Standardabweichungen über eine Datenreihe zeigt, nach Tikz exportiert unter Verwendung von matlab2tikz (siehe https://de.mathworks.com/matlabcentral/ ... atlab2tikz). Mein Problem ist, dass das Ergebnis wie anbei zu sehen nicht sehr ansprechend aussieht. Etwas störend ist, dass auf jedem Balken an der Position des Mittelwertes ein großer schwarzer Punkt sitzt. Das zweite Problem ist, dass die Standardabweichung auf den Balken darunter komplett untergeht.

Weiß jemand, wie ich mein Balkendiagramm nachträglich anpassen kann, um das zu heben.

Mein Code hierzu sieht wie folgt aus:
\begin{tikzpicture}

\begin{axis}[%
width=\figurewidth,
height=0.896\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
log origin=infty,
xmin=0.5,
xmax=20.5,
xtick={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
xlabel={Data set},
ymin=0.795949840594,
ymax=0.991849088141675,
ylabel={SSIM},
axis background/.style={fill=white},
axis x line*=bottom,
axis y line*=left,
legend style={at={(0.5,1.03)},anchor=south,legend columns=3,legend cell align=left,align=left,draw=white!15!black}
]
\addplot[ybar,bar width=0.178,bar shift=-0.222,fill=black,draw=black,area legend] plot table[row sep=crcr] {%
1	0.900565421295004\\
2	0.878669798275559\\
3	0.810229999693322\\
4	0.954030858461746\\
5	0.943874250454377\\
6	0.92352254287942\\
7	0.916614996827754\\
8	0.859040446462583\\
9	0.861741504474348\\
10	0.866646878198409\\
11	0.910728866761752\\
12	0.838836862370746\\
13	0.901557580330208\\
14	0.835616868467352\\
15	0.965940610846019\\
16	0.83630448613596\\
17	0.865806757464395\\
18	0.920784764928997\\
19	0.923750383904336\\
20	0.903054491879658\\
};
%\addlegendentry{SEQ};

\addplot[ybar,bar width=0.178,fill=blue,draw=black,area legend] plot table[row sep=crcr] {%
1	0.9262355473898\\
2	0.894421258757148\\
3	0.842361000813314\\
4	0.972450408756463\\
5	0.962827891482068\\
6	0.938894629430541\\
7	0.945158997579809\\
8	0.880365546437937\\
9	0.898315175200526\\
10	0.916020845321953\\
11	0.937202262552132\\
12	0.909147130936477\\
13	0.941266387388442\\
14	0.860345824146589\\
15	0.975750373738602\\
16	0.871032171224459\\
17	0.901435207602136\\
18	0.951699099224546\\
19	0.958633201066522\\
20	0.918759439968499\\
};
%\addlegendentry{IDP};

\addplot[ybar,bar width=0.178,bar shift=0.222,fill=green,draw=black,area legend] plot table[row sep=crcr] {%
1	0.932957459877189\\
2	0.900697695539171\\
3	0.848352633340068\\
4	0.979865852466281\\
5	0.97536963862276\\
6	0.948476512553129\\
7	0.951967799515343\\
8	0.901310454424156\\
9	0.920966718638636\\
10	0.930643132334344\\
11	0.94874533714589\\
12	0.927043308291485\\
13	0.948659802247063\\
14	0.873064960251883\\
15	0.981383014562009\\
16	0.878708749560312\\
17	0.918312089724085\\
18	0.962212914765693\\
19	0.964206585629485\\
20	0.924848099709592\\
};
%\addlegendentry{LLR};

\addplot [color=black,line width=2.0pt,forget plot,only marks,mark=none]
 plot [error bars/.cd, y dir = both, y explicit]
 table[row sep=crcr, y error plus index=2, y error minus index=3]{%
0.777777777777778	0.900565421295004	0.000846862762140821	0.000846862762140821\\
1.77777777777778	0.878669798275559	0.00134285366319028	0.00134285366319028\\
2.77777777777778	0.810229999693322	0.00251829236516653	0.00251829236516653\\
3.77777777777778	0.954030858461746	0.000645528672990524	0.000645528672990524\\
4.77777777777778	0.943874250454377	0.000893751826210922	0.000893751826210922\\
5.77777777777778	0.92352254287942	0.000707888343934613	0.000707888343934613\\
6.77777777777778	0.916614996827754	0.00117716929654972	0.00117716929654972\\
7.77777777777778	0.859040446462583	0.000841084563851988	0.000841084563851988\\
8.77777777777778	0.861741504474348	0.00118442204410107	0.00118442204410107\\
9.77777777777778	0.866646878198409	0.00160141430661583	0.00160141430661583\\
10.7777777777778	0.910728866761752	0.000903840465440695	0.000903840465440695\\
11.7777777777778	0.838836862370746	0.00159115186857136	0.00159115186857136\\
12.7777777777778	0.901557580330208	0.00122995951882896	0.00122995951882896\\
13.7777777777778	0.835616868467352	0.00192927151010272	0.00192927151010272\\
14.7777777777778	0.965940610846019	0.000306372303096744	0.000306372303096744\\
15.7777777777778	0.83630448613596	0.00100642222944413	0.00100642222944413\\
16.7777777777778	0.865806757464395	0.00123758381895015	0.00123758381895015\\
17.7777777777778	0.920784764928997	0.000983207056585198	0.000983207056585198\\
18.7777777777778	0.923750383904336	0.000817501834306771	0.000817501834306771\\
19.7777777777778	0.903054491879658	0.00105351955558176	0.00105351955558176\\
};
\addplot [color=black,line width=2.0pt,forget plot,only marks,mark=none]
 plot [error bars/.cd, y dir = both, y explicit]
 table[row sep=crcr, y error plus index=2, y error minus index=3]{%
1	0.9262355473898	0.00102778413372469	0.00102778413372469\\
2	0.894421258757148	0.00179127270688888	0.00179127270688888\\
3	0.842361000813314	0.0028673147329666	0.0028673147329666\\
4	0.972450408756463	0.000302786281164373	0.000302786281164373\\
5	0.962827891482068	0.000296000126603498	0.000296000126603498\\
6	0.938894629430541	0.00087822952610881	0.00087822952610881\\
7	0.945158997579809	0.00105089126980109	0.00105089126980109\\
8	0.880365546437937	0.00120422154867488	0.00120422154867488\\
9	0.898315175200526	0.00126746754466705	0.00126746754466705\\
10	0.916020845321953	0.00116618671034853	0.00116618671034853\\
11	0.937202262552132	0.000596510664486316	0.000596510664486316\\
12	0.909147130936477	0.000946073052925447	0.000946073052925447\\
13	0.941266387388442	0.000629896720104476	0.000629896720104476\\
14	0.860345824146589	0.00205023609847753	0.00205023609847753\\
15	0.975750373738602	0.000293955336907366	0.000293955336907366\\
16	0.871032171224459	0.00124491318715241	0.00124491318715241\\
17	0.901435207602136	0.00203367654426122	0.00203367654426122\\
18	0.951699099224546	0.00061877530073262	0.00061877530073262\\
19	0.958633201066522	0.000507184225539747	0.000507184225539747\\
20	0.918759439968499	0.00141230045533339	0.00141230045533339\\
};
\addplot [color=black,line width=2.0pt,forget plot,only marks,mark=none]
 plot [error bars/.cd, y dir = both, y explicit]
 table[row sep=crcr, y error plus index=2, y error minus index=3]{%
1.22222222222222	0.932957459877189	0.00103883980415951	0.00103883980415951\\
2.22222222222222	0.900697695539171	0.00178432632764541	0.00178432632764541\\
3.22222222222222	0.848352633340068	0.0026467078765393	0.0026467078765393\\
4.22222222222222	0.979865852466281	0.000173466241375569	0.000173466241375569\\
5.22222222222222	0.97536963862276	0.00031561325551989	0.00031561325551989\\
6.22222222222222	0.948476512553129	0.000806343882668242	0.000806343882668242\\
7.22222222222222	0.951967799515343	0.00102772547881446	0.00102772547881446\\
8.22222222222222	0.901310454424156	0.00163065698414342	0.00163065698414342\\
9.22222222222222	0.920966718638636	0.00135676328810645	0.00135676328810645\\
10.2222222222222	0.930643132334344	0.00104373572055742	0.00104373572055742\\
11.2222222222222	0.94874533714589	0.000580533430533879	0.000580533430533879\\
12.2222222222222	0.927043308291485	0.000978642903235579	0.000978642903235579\\
13.2222222222222	0.948659802247063	0.000686403523396097	0.000686403523396097\\
14.2222222222222	0.873064960251883	0.00231198452104443	0.00231198452104443\\
15.2222222222222	0.981383014562009	0.000272315708871675	0.000272315708871675\\
16.2222222222222	0.878708749560312	0.00136071622184987	0.00136071622184987\\
17.2222222222222	0.918312089724085	0.00222455879826484	0.00222455879826484\\
18.2222222222222	0.962212914765693	0.000639889380633259	0.000639889380633259\\
19.2222222222222	0.964206585629485	0.000572142715302141	0.000572142715302141\\
20.2222222222222	0.924848099709592	0.00157718004300972	0.00157718004300972\\
};
\end{axis}
\end{tikzpicture}%
Viele Grüße

Thomas

Verfasst: Di 29. Nov 2016, 23:34
von Bartman
Ein vollständiges Beispiel erhöht die Wahrscheinlichkeit, eine hilfreiche Antwort zu bekommen.

Verfasst: Mi 30. Nov 2016, 00:02
von TK1985
Das einzige was halt noch fehlt ist das Einbinden in einer figure:
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{tikz-3dplot}

...

\begin{document}

\begin{figure}[!t]
	\centering
	\scriptsize 
	\setlength \figurewidth{0.94\textwidth}
	\setlength \figureheight{0.265\figurewidth} 
	\subfloat{\input{...} // --> Einbinden der Tikz Datei
\end{figure}

...

\end{document}
Ich denke das Problem liegt an einem der Parameter, die in der Tikz Datei (siehe oben) angegeben sind. Hat jemand eine Idee, wie ich die Standardabweichungen auf den Balken sichtbar bekomme?

Verfasst: Mi 30. Nov 2016, 07:15
von markusv
TK1985 hat geschrieben:Das einzige was halt noch fehlt ist das Einbinden in einer figure
Nein. Auch dann ist es kein Minimalbeispiel.
Da fehlt zumindest schon mal die Angabe der Dokumentenklasse.

Am \subfloat-Befehl lässt sich vermuten, dass das subfig-Paket benötigt wird, die Längen (z.B \figurewidth) sind nicht definiert, etc. pp.

Selbst der geneigte Helfer wird sich kein lauffähiges Dokument zusammen basteln, um dir zu helfen. Außerdem kann der Helfer nicht davon ausgehen, mit seinen Ergänzungen dein Problem reproduzieren zu können.

Verfasst: Mi 30. Nov 2016, 08:13
von TK1985
Nunja, komisch das ich die gepostete Tikz-Datei in jedes x-beliebige Dokument mit Angabe der Längen einfügen kann und das Problem exakt reproduzieren kann :roll: Hab nun jedenfalls selber einen Workaround gefunden.

Verfasst: Mi 30. Nov 2016, 08:48
von Johannes_B
Das erinnert mich an eine ähnliche Reaktion auf die Fordeung eines Minimalbeispiels, um eine Frage überhaupt losen zu können. Ohne zu puzzlen.