Matlab2tikz und Plotyy

Tabellen und Grafiken erstellen und anordnen


Flex87
Forum-Newbie
Forum-Newbie
Beiträge: 5
Registriert: Sa 26. Okt 2013, 11:50

Matlab2tikz und Plotyy

Beitrag von Flex87 »

Hallo liebe Community,

ich hoffe ich bin mit meiner Frage bei euch richtig, da sie sowohl LaTex als auch Matlab betrifft.

Ich habe in Matlab eine Grafik erstellt, die aus vier subplots besteht mit jeweils 2 y-Achsen. Funktioniert soweit wunderbar. Mein Problem ist ich binde diese Grafiken mittels matlab2tikz in LaTex ein. Das scheint hier ein Problem zu sein. Ich habe leider im Internet nichts zu meinem Problem finden können. Denke das Problem liegt eher bei LaTex als bei Matlab deswegen schreibe ich bei euch in das Forum.
Ich hänge euch mal ein Bild an das mein Problem verdeutlicht.
Hier der Tex-Code:
% This file was created by matlab2tikz v0.3.3.
% Copyright (c) 2008--2013, Nico Schlömer <nico.schloemer@gmail.com>
% All rights reserved.
% 
% The latest updates can be retrieved from
%   http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz
% where you can also make suggestions and rate matlab2tikz.
% 
% 
% 
\begin{tikzpicture}

\begin{axis}[%
width=0.35\textwidth,
height=0.25\textwidth,
scale only axis,
xmin=0,
xmax=100,
xmajorgrids,
ymin=-1,
ymax=1,
ytick={  -1, -0.5,    0,  0.5,    1},
ymajorgrids,
name=plot1,
axis line style={->},
xticklabel style={align=center},
scaled ticks=false,
legend pos=north west
]
\addplot [
color=black,
solid,
forget plot
]
table[row sep=crcr]{
0 0\\
1 0.841470984807897\\
2 0.909297426825682\\
3 0.141120008059867\\
4 -0.756802495307928\\
5 -0.958924274663138\\
6 -0.279415498198926\\
7 0.656986598718789\\
8 0.989358246623382\\

};
\addplot [
color=blue,
solid,
forget plot
]
table[row sep=crcr]{
0 1\\
1 0.54030230586814\\
2 -0.416146836547142\\
3 -0.989992496600445\\
4 -0.653643620863612\\
5 0.283662185463226\\
6 0.960170286650366\\
7 0.753902254343305\\
8 -0.145500033808614\\
};
\end{axis}

\begin{axis}[%
width=0.35\textwidth,
height=0.25\textwidth,
scale only axis,
xmin=0,
xmax=100,
ymin=0,
ymax=200,
ytick={  0,  50, 100, 150, 200},
name=plot5,
axis x line*=bottom,
axis y line*=right,
axis line style={->},
xticklabel style={align=center},
scaled ticks=false,
legend pos=north west
]
\addplot [
color=red,
dotted,
forget plot
]
table[row sep=crcr]{
0 2\\
1 4\\
2 6\\
3 8\\
4 10\\
5 12\\
6 14\\
7 16\\
8 18\\

};
\end{axis}

\begin{axis}[%
width=0.35\textwidth,
height=0.25\textwidth,
scale only axis,
xmin=0,
xmax=100,
ymin=0,
ymax=200,
ytick={  0,  50, 100, 150, 200},
name=plot6,
at=(plot5.below south west),
anchor=above north west,
axis x line*=bottom,
axis y line*=right,
axis line style={->},
xticklabel style={align=center},
scaled ticks=false,
legend pos=north west
]
\addplot [
color=red,
dotted,
forget plot
]
table[row sep=crcr]{
0 2\\
1 4\\
2 6\\
3 8\\
4 10\\
5 12\\
6 14\\
7 16\\
8 18\\

};
\end{axis}

\begin{axis}[%
width=0.35\textwidth,
height=0.25\textwidth,
scale only axis,
xmin=0,
xmax=100,
xmajorgrids,
ymin=-10,
ymax=10,
ytick={-10,  -5,   0,   5,  10},
ymajorgrids,
name=plot3,
axis line style={->},
xticklabel style={align=center},
scaled ticks=false,
legend pos=north west
]
\addplot [
color=black,
solid,
forget plot
]
table[row sep=crcr]{
0 0\\
1 8.41470984807897\\
2 9.09297426825682\\
3 1.41120008059867\\
4 -7.56802495307928\\
5 -9.58924274663138\\
6 -2.79415498198926\\
7 6.56986598718789\\
8 9.89358246623382\\

};
\addplot [
color=blue,
solid,
forget plot
]
table[row sep=crcr]{
0 10\\
1 5.4030230586814\\
2 -4.16146836547142\\
3 -9.89992496600445\\
4 -6.53643620863612\\
5 2.83662185463226\\
6 9.60170286650366\\
7 7.53902254343305\\
8 -1.45500033808614\\
};
\end{axis}

\begin{axis}[%
width=0.35\textwidth,
height=0.25\textwidth,
scale only axis,
xmin=0,
xmax=100,
xmajorgrids,
ymin=-20,
ymax=20,
ytick={-20,   0,  20},
ymajorgrids,
name=plot4,
at=(plot3.right of south east),
anchor=left of south west,
axis line style={->},
xticklabel style={align=center},
scaled ticks=false,
legend pos=north west
]
\addplot [
color=black,
solid,
forget plot
]
table[row sep=crcr]{
0 3\\
1 11.414709848079\\
2 12.0929742682568\\
3 4.41120008059867\\
4 -4.56802495307928\\
5 -6.58924274663138\\
6 0.205845018010741\\
7 9.56986598718789\\
8 12.8935824662338\\
};
\addplot [
color=blue,
solid,
forget plot
]
table[row sep=crcr]{
0 13\\
1 8.4030230586814\\
2 -1.16146836547142\\
3 -6.89992496600445\\
4 -3.53643620863612\\
5 5.83662185463226\\
6 12.6017028665037\\
7 10.539022543433\\
8 1.54499966191386\\
};
\end{axis}

\begin{axis}[%
width=0.35\textwidth,
height=0.25\textwidth,
scale only axis,
xmin=0,
xmax=100,
ymin=0,
ymax=400,
ytick={  0, 200, 400},
name=plot8,
axis x line*=bottom,
axis y line*=right,
axis line style={->},
xticklabel style={align=center},
scaled ticks=false,
legend pos=north west
]
\addplot [
color=red,
dotted,
forget plot
]
table[row sep=crcr]{
0 4\\
1 8\\
2 12\\
3 16\\
4 20\\
5 24\\
6 28\\
7 32\\
8 36\\
};
\end{axis}

\begin{axis}[%
width=0.35\textwidth,
height=0.25\textwidth,
scale only axis,
xmin=0,
xmax=100,
ymin=0,
ymax=400,
ytick={  0, 100, 200, 300, 400},
at=(plot8.above north west),
anchor=below south west,
axis x line*=bottom,
axis y line*=right,
axis line style={->},
xticklabel style={align=center},
scaled ticks=false,
legend pos=north west
]
\addplot [
color=red,
dotted,
forget plot
]
table[row sep=crcr]{
0 4\\
1 8\\
2 12\\
3 16\\
4 20\\
5 24\\
6 28\\
7 32\\
8 36\\
};
\end{axis}

\begin{axis}[%
width=0.35\textwidth,
height=0.25\textwidth,
scale only axis,
xmin=0,
xmax=100,
xmajorgrids,
ymin=2,
ymax=4,
ytick={  2, 2.5,   3, 3.5,   4},
ymajorgrids,
axis line style={->},
xticklabel style={align=center},
scaled ticks=false,
legend pos=north west
]
\addplot [
color=black,
solid,
forget plot
]
table[row sep=crcr]{
0 3\\
1 3.8414709848079\\
2 3.90929742682568\\
3 3.14112000805987\\
4 2.24319750469207\\
5 2.04107572533686\\
6 2.72058450180107\\
7 3.65698659871879\\
8 3.98935824662338\\
};
\addplot [
color=blue,
solid,
forget plot
]
table[row sep=crcr]{
0 4\\
1 3.54030230586814\\
2 2.58385316345286\\
3 2.01000750339955\\
4 2.34635637913639\\
5 3.28366218546323\\
6 3.96017028665037\\
7 3.7539022543433\\
8 2.85449996619139\\
};
\end{axis}
\end{tikzpicture}%
Ich hoffe Ihr könnt mir da irgendwie weiterhelfen, bekomme das leider alleine nicht gelöst.
Vielen Dank und ein schönes Wochenende!

Felix

Edit: Leider funktioniert das Hochladen der jpg-Datei nicht :(

feuersaenger
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 91
Registriert: Mi 5. Okt 2011, 18:24
Wohnort: Rheinbach

Beitrag von feuersaenger »

Hi,

es scheint, dass matlab2tikz da Schwierigkeiten bei der Interpretation der verscheidenen Achsen hat.

Generell sollte das aber kein Problem sein; ein Anhaltspunkt sollte der Abschnitt "alignment" im pgfplots reference manual unter http://pgfplots.sourceforge.net/ sein. Da gibt es mehrere Loesungsansaetze im Manual.

Es gibt auch hin- und wieder mal Fragen in online foren, die mit subfigure beantwortet wurden - darin ist jeder subplot eine subfigure mit eigener Achsenbeschriftung. Eine google oder foren suche nach pgfplots und subfigure hilft da vielleicht weiter.

Ich hoffe, das hilft Dir erstmal weiter. Gegenenfalls ist vielleicht auch Niko Schloemer, der Author von matlab2tikz, an Deiner Loesung fuer das Problem interessiert. Der haette dann vermutlich auch gerne matlab code.

Mit liebem Gruss

Christian

Antworten