9

I currently have the following:

plots

Now as you can probably imagine I do not want this. I want the upper right plot to be aligned with the lower right plot. However when I do this, using the at and anchor statements, the plot slightly drops and is not aligned anymore with the upper left plot. My question is how do I fix this? To be clear I want the upper right plot to be aligned with the upper left plot and the lower right plot.

I have the following code, note I removed the data from the plots because it are pretty many points.

\documentclass[a4paper,11pt,twoside]{article}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}[scale=0.7]

\begin{semilogxaxis}[%
view={0}{90},
width=10cm,
height=5cm,
scale only axis,
every outer x axis line/.append style={gray!80!black},
every x tick label/.append style={font=\color{gray!80!black}},
xmin=0.1, xmax=1000,
xlabel={Frequency (rad/s)},
xminorticks=true,
xmajorgrids,
xminorgrids,
every outer y axis line/.append style={gray!80!black},
every y tick label/.append style={font=\color{gray!80!black}},
ymin=-200, ymax=200,
ylabel={Phase (deg)},
ymajorgrids,
name=plot1]

\addplot [
color=blue,
solid,
line width=1.5pt,
forget plot
]
coordinates{
 (0,0)
};

\end{semilogxaxis}

\begin{semilogxaxis}[%
view={0}{90},
width=10cm,
height=5cm,
scale only axis,
every outer x axis line/.append style={gray!80!black},
every x tick label/.append style={font=\color{gray!80!black}},
xmin=0.1, xmax=1000,
xticklabels={\empty}
xminorticks=true,
xmajorgrids,
xminorgrids,
every outer y axis line/.append style={gray!80!black},
every y tick label/.append style={font=\color{gray!80!black}},
ymin=-350, ymax=50,
ylabel={Magnitude (dB)},
ymajorgrids,
at=(plot1.above north west), 
anchor=below south west,
name=plot2]

\addplot [
color=blue,
solid,
line width=1.5pt,
forget plot
]
coordinates{
 (0,-76.9482975559457)
};

\end{semilogxaxis}

\begin{semilogxaxis}[%
view={0}{90},
width=10cm,
height=5cm,
scale only axis,
every outer x axis line/.append style={gray!80!black},
every x tick label/.append style={font=\color{gray!80!black}},
xmin=0.1, xmax=1000,
xlabel={Frequency (rad/s)},
xminorticks=true,
xmajorgrids,
xminorgrids,
every outer y axis line/.append style={gray!80!black},
every y tick label/.append style={font=\color{gray!80!black}},
ymin=-200, ymax=200,
yticklabels={\empty},
ymajorgrids,
at=(plot1.right of south east), 
anchor=left of south west,
name=plot3]

\addplot [
color=blue,
solid,
line width=1.5pt,
forget plot
]
coordinates{
 (0,0)
};

\end{semilogxaxis}

\begin{semilogxaxis}[%
view={0}{90},
width=10cm,
height=5cm,
scale only axis,
every outer x axis line/.append style={gray!80!black},
every x tick label/.append style={font=\color{gray!80!black}},
xmin=0.1, xmax=1000,
xticklabels={\empty}
xminorticks=true,
xmajorgrids,
xminorgrids,
every outer y axis line/.append style={gray!80!black},
every y tick label/.append style={font=\color{gray!80!black}},
yticklabels={\empty},
ymin=-350, ymax=50,
ymajorgrids,
at={(plot2.right of south east)}, 
anchor={left of south west},
name=plot4]

\addplot [
color=blue,
solid,
line width=1.5pt,
forget plot
]
coordinates{
 (0,-47.4053700922616)
};

\end{semilogxaxis}
\end{tikzpicture}
\end{document}
Stefan Kottwitz
  • 231,401
WG-
  • 2,860

1 Answers1

9

The reason why these are not aligned as you expect is that the second graph does not have the x-axis labels. This can be achieved by setting the widths of the labels:

\pgfplotsset{xticklabel style={text width=2em,align=right}}

which yields:

enter image description here

References:

Code:

\documentclass[a4paper,11pt,twoside]{article}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}[scale=0.7]

\pgfplotsset{xticklabel style={text width=2em,align=right}}% <--- Added

\begin{semilogxaxis}[% view={0}{90}, width=10cm, height=5cm, scale only axis, every outer x axis line/.append style={gray!80!black}, every x tick label/.append style={font=\color{gray!80!black}}, xmin=0.1, xmax=1000, xlabel={Frequency (rad/s)}, xminorticks=true, xmajorgrids, xminorgrids, every outer y axis line/.append style={gray!80!black}, every y tick label/.append style={font=\color{gray!80!black}}, ymin=-200, ymax=200, ylabel={Phase (deg)}, ymajorgrids, name=plot1]

\addplot [ color=blue, solid, line width=1.5pt, forget plot ] coordinates{ (0,0) };

\end{semilogxaxis}

\begin{semilogxaxis}[% view={0}{90}, width=10cm, height=5cm, scale only axis, every outer x axis line/.append style={gray!80!black}, every x tick label/.append style={font=\color{gray!80!black}}, xmin=0.1, xmax=1000, xticklabels={\empty} xminorticks=true, xmajorgrids, xminorgrids, every outer y axis line/.append style={gray!80!black}, every y tick label/.append style={font=\color{gray!80!black}}, ymin=-350, ymax=50, ylabel={Magnitude (dB)}, ymajorgrids, at=(plot1.above north west), anchor=below south west, name=plot2]

\addplot [ color=blue, solid, line width=1.5pt, forget plot ] coordinates{ (0,-76.9482975559457) };

\end{semilogxaxis}

\begin{semilogxaxis}[% view={0}{90}, width=10cm, height=5cm, scale only axis, every outer x axis line/.append style={gray!80!black}, every x tick label/.append style={font=\color{gray!80!black}}, xmin=0.1, xmax=1000, xlabel={Frequency (rad/s)}, xminorticks=true, xmajorgrids, xminorgrids, every outer y axis line/.append style={gray!80!black}, every y tick label/.append style={font=\color{gray!80!black}}, ymin=-200, ymax=200, yticklabels={\empty}, ymajorgrids, at=(plot1.right of south east), anchor=left of south west, name=plot3]

\addplot [ color=blue, solid, line width=1.5pt, forget plot ] coordinates{ (0,0) };

\end{semilogxaxis}

\begin{semilogxaxis}[% view={0}{90}, width=10cm, height=5cm, scale only axis, every outer x axis line/.append style={gray!80!black}, every x tick label/.append style={font=\color{gray!80!black}}, xmin=0.1, xmax=1000, xticklabels={\empty} xminorticks=true, xmajorgrids, xminorgrids, every outer y axis line/.append style={gray!80!black}, every y tick label/.append style={font=\color{gray!80!black}}, yticklabels={\empty}, ymin=-350, ymax=50, ymajorgrids, at={(plot2.right of south east)}, anchor={left of south west}, name=plot4]

\addplot [ color=blue, solid, line width=1.5pt, forget plot ] coordinates{ (0,-47.4053700922616) };

\end{semilogxaxis} \end{tikzpicture} \end{document}

Peter Grill
  • 223,288
  • Thank you for your comment. I however do not want to eleminate xticklabels={\empty} at the left upper plot or either the right upper plot. Because the plots all align with each other I only want to display the x- or yticklabels when it is needed. – WG- Sep 14 '12 at 19:49
  • 1
    Sorry, I had used \pgfplotsset{yticklabel... instead of \pgfplotsset{xticklabel... Have corrected. – Peter Grill Sep 14 '12 at 20:54