5

I am trying to get the vertical axes aligned in the following figure but having trouble. In particular, the y-axis of the first and last figure in the 3rd row have to be aligned with those of the previous rows. Other issues are:

  1. asterisk and the equal to signs are not at the center,
  2. the figures in the last column are not to scale, and
  3. the font is too big.

Thanks.

enter image description here

\documentclass[aspectratio=169,11pt]{beamer}
\mode<presentation>

\usepackage{pgfpages,mathtools}

\usepackage{pgfplots}
\usepackage{tikz}

\usetikzlibrary{arrows,plotmarks}
\usetikzlibrary{matrix}

\usetheme{Boadilla}
\date{}

\begin{document}

\begin{frame}
  \frametitle{Examples}
  \begin{tikzpicture}[ampersand replacement=\&,baseline=(current bounding box.center)]
  \matrix{
    \begin{axis}[axis lines=middle, xtick={0,4},
     xticklabels={0,$T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     height=3cm,
     xlabel={\empty}, x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& \node (conv1) {$\ast$};

   \&\begin{axis}[%
     axis lines=middle, xtick={0,4},
     xticklabels={0,$T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     height=3cm,
     xlabel={\empty}, x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& \node (equal1) {$=$};

   \&\begin{axis}[%
     axis lines=middle, xtick={0,4,8},
     xticklabels={0,$T$,$2T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$T$},
     height=3cm,
     xlabel={\empty}, x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west}]
     \addplot+[very thick,mark=none]
     coordinates
     {(0,0) (4,1) (8,0)};
   \end{axis}\\

   \begin{axis}[axis lines=middle, xtick={0,8},
     xticklabels={0,$2T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     height=3cm,
     xlabel={\empty}, x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (8,0)};
   \end{axis}

   \& \node (conv2) {$\ast$};

   \&\begin{axis}[axis lines=middle, xtick={0,4},
     xticklabels={0,$T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     height=3cm,
     xlabel={\empty}, x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& \node (equal2) {$=$};

   \&\begin{axis}[axis lines=middle, xtick={0,4,8,12},
     xticklabels={0,$T$,$2T$,$3T$},ymin=0, ymax=1.2,
     xmin=0,xmax=13,ytick={1},yticklabels={$T$},
     height=3cm,
     xlabel={\empty}, x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west}]
     \addplot+[very thick,mark=none]
     coordinates
     {(0,0) (4,1) (8,1) (12,0)};
   \end{axis}\\

   \begin{axis}[axis lines=middle, xtick={-4,0},
     xticklabels={$-T$,0},ymin=0, ymax=1.2,
     xmin=-5,xmax=5,ytick={1},yticklabels={$1$},
     height=3cm,
     y tick label style={anchor=west},
     xlabel={\empty}, x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(-4,0) (-4,1) (0,0)};
   \end{axis}

   \& \node (conv3) {$\ast$};

   \&\begin{axis}[axis lines=middle, xtick={0,4},
     xticklabels={0,$T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     height=3cm,
     xlabel={\empty}, x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& \node (equal3) {$=$};

   \&\begin{axis}[axis lines=middle, xtick={-4,0,4},
     xticklabels={$-T$,$0$,$T$},ymin=0, ymax=1.2,
     xmin=-5,xmax=5,ytick={1},yticklabels={$T$},
     height=3cm,
     xlabel={\empty}, x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west}]
     \addplot+[very thick,mark=none]
     coordinates
     {(-4,0) (0,1) (4,0)};
   \end{axis}\\
 };
\end{tikzpicture}%
\end{frame}

\end{document}
2
  • Why not setting xmin and xmax to the same values for each graph? The font size can be reduced using \pgfplotsset{every tick label/.append style={font=\scriptsize}}
    – epR8GaYuh
    Jan 13, 2017 at 6:36
  • Making xmin and xmax resulted in the axes being aligned. Thanks. Is there a way for aligning them without making xmin and xmax the same? Just curious. The fonts are also now better, following your suggestion. The only issue remaining is moving the "*" and "=" signs to the center. Has this to be done manually?
    – CSR
    Jan 13, 2017 at 6:57

2 Answers 2

9

If you add

every axis/.append style={
footnotesize,
height=3cm,
unit vector ratio=1 4 1,
execute at end axis={
   \coordinate (O) at (current axis.east -| current axis.origin);
   },
anchor=O,

to the tikzpicture options, you get

enter image description here

Does that look better? (The common settings added in the every axis style is removed from the individual axes.)

Note also that xlabel=\empty is kind of strange. The \empty macro is intended for ticks (xtick/ytick/ztick), for the case where you don't want any ticks at all. If you don't need an xlabel, just remove xlabel=.. altogether. (And then you can also remove the x label style of course.)

\documentclass[aspectratio=169,11pt]{beamer}
\mode<presentation>

\usepackage{pgfpages,mathtools}

\usepackage{pgfplots}

\usetikzlibrary{arrows,plotmarks}
\usetikzlibrary{matrix}

\usetheme{Boadilla}
\date{}

\begin{document}

\begin{frame}
  \frametitle{Examples}
  \begin{tikzpicture}[
   ampersand replacement=\&,
   baseline=(current bounding box.center),
   every axis/.append style={
    footnotesize,
    height=3cm,
    unit vector ratio=1 4 1,
    execute at end axis={
       \coordinate (O) at (current axis.east -| current axis.origin);
       },
    anchor=O
    }
   ]
  \matrix{
    \begin{axis}[axis lines=middle, xtick={0,4},
     xticklabels={0,$T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     ]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& \node (conv1) {$\ast$};

   \&\begin{axis}[%
     axis lines=middle, xtick={0,4},
     xticklabels={0,$T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     ]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& \node (equal1) {$=$};

   \&\begin{axis}[%
     axis lines=middle, xtick={0,4,8},
     xticklabels={0,$T$,$2T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$T$},
     ]
     \addplot+[very thick,mark=none]
     coordinates
     {(0,0) (4,1) (8,0)};
   \end{axis}\\

   \begin{axis}[axis lines=middle, xtick={0,8},
     xticklabels={0,$2T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     ]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (8,0)};
   \end{axis}

   \& \node (conv2) {$\ast$};

   \&\begin{axis}[axis lines=middle, xtick={0,4},
     xticklabels={0,$T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     ]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& \node (equal2) {$=$};

   \&\begin{axis}[axis lines=middle, xtick={0,4,8,12},
     xticklabels={0,$T$,$2T$,$3T$},ymin=0, ymax=1.2,
     xmin=0,xmax=13,ytick={1},yticklabels={$T$},
     ]
     \addplot+[very thick,mark=none]
     coordinates
     {(0,0) (4,1) (8,1) (12,0)};
   \end{axis}\\

   \begin{axis}[axis lines=middle, xtick={-4,0},
     xticklabels={$-T$,0},ymin=0, ymax=1.2,
     xmin=-5,xmax=5,ytick={1},yticklabels={$1$},
     y tick label style={anchor=west},
     ]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(-4,0) (-4,1) (0,0)};
   \end{axis}

   \& \node (conv3) {$\ast$};

   \&\begin{axis}[axis lines=middle, xtick={0,4},
     xticklabels={0,$T$},ymin=0, ymax=1.2,
     xmin=0,xmax=10,ytick={1},yticklabels={$1$},
     ]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& \node (equal3) {$=$};

   \&\begin{axis}[axis lines=middle, xtick={-4,0,4},
     xticklabels={$-T$,$0$,$T$},ymin=0, ymax=1.2,
     xmin=-5,xmax=5,ytick={1},yticklabels={$T$},
     ]
     \addplot+[very thick,mark=none]
     coordinates
     {(-4,0) (0,1) (4,0)};
   \end{axis}\\
 };
\end{tikzpicture}%
\end{frame}
\end{document}
1
  • Thanks so much, everyone. The above is indeed what I want. I had not stated clearly in my original post that I wanted "*" and "=" to be in the center vertically, as given in the above solution. Thanks to the other solutions as well.
    – CSR
    Jan 13, 2017 at 8:41
4

Here a solution to center \ast and = symbols between plots

  • First you need to name plots with name= A,B,...,I.
  • Then you can place nodes containing \ast and = symbols like this

 \foreach \i/\j in {A/B,D/E,G/H}
{\path (\i.south east)--node{$\ast$}(\j.south west);}
\foreach \i/\j in {B/C,E/F,H/I}
{\path (\i.south east)--node{$=$}(\j.south west);} 

Complete Code

\documentclass[aspectratio=169,11pt]{beamer}
\mode<presentation>

\usepackage{pgfpages,mathtools}

\usepackage{pgfplots}

\usetikzlibrary{arrows,plotmarks}
\usetikzlibrary{matrix}

\usetheme{Boadilla}
\date{}

\begin{document}

\begin{frame}
  \frametitle{Examples}
  \begin{tikzpicture}[ampersand replacement=\&,baseline=(current bounding box.center),
  every axis/.append style={ymin=0, ymax=1.2,height=3cm,
     font=\scriptsize,xlabel={\empty}, 
     x label style={anchor=north},
     ylabel={\empty}, y label style={anchor=west},
     axis lines=middle,,xmin=0,xmax=10}]

  \matrix[column sep=3mm]{
    \begin{axis}[name=A,axis lines=middle, xtick={0,4},
     xticklabels={0,$T$},yticklabels={$1$},ytick={1}]
          \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& 

   \&\begin{axis}[%
     name=B, xtick={0,4},
     xticklabels={0,$T$},ytick={1},yticklabels={$1$}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& 

   \&\begin{axis}[%
     name=C, xtick={0,4,8},
     xticklabels={0,$T$,$2T$},ytick={1},yticklabels={$T$}]
     \addplot+[very thick,mark=none]
     coordinates
     {(0,0) (4,1) (8,0)};
   \end{axis}\\

   \begin{axis}[name=D, xtick={0,8},
     xticklabels={0,$2T$},ytick={1},yticklabels={$1$}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (8,0)};
   \end{axis}

   \& 

   \&\begin{axis}[name=E, xtick={0,4},
     xticklabels={0,$T$},
     ytick={1},yticklabels={$1$}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& 

   \&\begin{axis}[name=F, xtick={0,4,8,12},
     xticklabels={0,$T$,$2T$,$3T$},
     xmax=13,ytick={1},yticklabels={$T$}]
     \addplot+[very thick,mark=none]
     coordinates
     {(0,0) (4,1) (8,1) (12,0)};
   \end{axis}\\

   \begin{axis}[name=G, xtick={-4,0},
     xticklabels={$-T$,0},
     xmin=-5,xmax=5,ytick={1},yticklabels={$1$}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(-4,0) (-4,1) (0,0)};
   \end{axis}

   \& 

   \&\begin{axis}[name=H, xtick={0,4},
     xticklabels={0,$T$},ytick={1},yticklabels={$1$}]
     \addplot+[very thick,mark=none,const plot]
     coordinates
     {(0,0) (0,1) (4,0)};
   \end{axis}

   \& 

   \&\begin{axis}[name=I, xtick={-4,0,4},
     xticklabels={$-T$,$0$,$T$},
     xmin=-5,xmax=5,ytick={1},yticklabels={$T$}]
     \addplot+[very thick,mark=none]
     coordinates
     {(-4,0) (0,1) (4,0)};
   \end{axis}\\
 };

 \foreach \i/\j in {A/B,D/E,G/H}
{\path (\i.south east)--node{$\ast$}(\j.south west);}
\foreach \i/\j in {B/C,E/F,H/I}
{\path (\i.south east)--node{$=$}(\j.south west);} 
\end{tikzpicture}%
\end{frame}

\end{document} enter image description here

3
  • Ehm, the y-axes are not aligned, and the \ast and = is not centered vertically on the axes, as requested. Jan 13, 2017 at 8:21
  • I think OP want \ast and = to be centered only horizontally.
    – Salim Bou
    Jan 13, 2017 at 8:27
  • Hm, perhaps you're right, it's not really clear. We'll see what (s)he says. (Of course, moving them up in your case is just a matter of removing south in the loops.) Jan 13, 2017 at 8:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .