8

I have the following plot. I changed the \addplot table command by an \addplot coordinates just to create a minimal example.

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots,units}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
group style={
    group size=1 by 2,
    horizontal sep=1.5cm,
    xlabels at=edge bottom,
    ylabels at=edge left,
},
width=7.3cm,
height=7.3cm,
scale only axis,
ymin=-4e-8,ymax=6e-8,
ytick distance=2e-8,
scaled x ticks=false,
change x base,
x SI prefix=nano,
x unit=s,
xlabel={time},
enlargelimits=false,
grid=major,
]
\nextgroupplot[
ylabel=$ s_{out,R} $,
]
\addplot[blue] coordinates { (0,-3e-8) (100e-9,5e-8) };
\nextgroupplot[ylabel=$ s_{out,I} $,]
\addplot[red] coordinates { (0,-3e-8) (100e-9,5e-8) };
\end{groupplot}
\end{tikzpicture}
\end{document}

Question: Is it possible to add an extra x-axis, labeled "frequency [GHz]" and ranging from 0.5 GHz to 3.5 GHz, below the "time [ns]" axis? (something similar to what have been done here Bell curve with multiple x-axes and annotations, or here How to add multiple x axes with different scaling?)

Thank you!

1 Answers1

7

A groupplot is just an axis really, so you can use the same idea: add a third plot in the group. You just need to change the options regarding xlabels and units a bit. For example:

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots,units}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
group style={
    group size=1 by 3,
    horizontal sep=1.5cm,
    ylabels at=edge left,
},
width=7.3cm,
height=7.3cm,
scale only axis,
ymin=-4e-8,ymax=6e-8,
ytick distance=2e-8,
scaled x ticks=false,
change x base,
x SI prefix=nano,
enlargelimits=false,
grid=major,
]
\nextgroupplot[
ylabel=$ s_{out,R} $,
]
\addplot[blue] coordinates { (0,-3e-8) (100e-9,5e-8) };
\nextgroupplot[ylabel=$ s_{out,I} $,xlabel={time},x unit=s]
\addplot[red] coordinates { (0,-3e-8) (100e-9,5e-8) };

\nextgroupplot[
  axis y line=none,
  axis x line=bottom,
  grid=none,
  xlabel=Frequency,
  x SI prefix=giga,
  x unit=Hz,
  xmin=0.5e9,
  xmax=3.5e9,
  height=0.2cm
]
\end{groupplot}
\end{tikzpicture}
\end{document}

(For this screenshot I reduced the height just to make it more compact.)

output of code with different height

Torbjørn T.
  • 206,688