0

The tick labels are not aligning with the axis, but they are sort of differently aligned. As marked by the red vertical line.

Image:

enter image description here

MWE Code:

\documentclass[12pt, a4paper,
                parskip=half,
                toc=bibliography,
                numbers=noendperiod
               ]{scrbook}

\usepackage[hmargin={3.0cm, 2.5cm}, vmargin={2.5cm, 2.0cm}, includehead, includefoot ]{geometry}

\usepackage[UKenglish]{babel} \usepackage[T1]{fontenc}

\usepackage{scrlayer-scrpage} \usepackage{subcaption} \usepackage{caption}

\setkomafont{captionlabel}{\bfseries\rmfamily}

\usepackage[dvipsnames,table,xcdraw]{xcolor} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage[font=normalsize]{subcaption}

\begin{document} \begin{figure}[ht] \pgfplotsset{ width=\linewidth, height=0.9\linewidth, enlarge y limits=0.1, %tick label style={font=\scriptsize}, xticklabel style = {text width=0.8em}, %ylabel style = {text width=1em, inner sep=2pt}, yticklabel style = {text width=2.0em, anchor= east}, label style={font=\bfseries\boldmath}, %tick label style={font=\bfseries\boldmath}, % %tick align = outside, tick pos = left, %every axis plot post/.append style={color=Blue, dashed, mark=}, } \begin{subfigure}[t]{0.48\linewidth} \begin{tikzpicture} \begin{loglogaxis}[ xmin=10, xmax=0.1e8, ymin=1e-8, ymax=1e2, xlabel={Number of Flops}, ylabel={Normalized MSE: $\log_{10} (e)$ }, scatter/classes={ a={mark=square, blue}, b={mark=square, red}, c={mark=square, black}, d={mark=triangle, blue}, e={mark=triangle, red},f={mark=triangle, black},g={mark=x, black}, h={mark= diamond*, pink} }, ] \addplot[scatter, only marks, scatter src=explicit symbolic] table[meta=label] { x y label 1320.9279232530525 0.9258769833615981 a

                                };
                        \end{loglogaxis}
                    \end{tikzpicture}
                \caption{Plot 1}
            \end{subfigure}
        \hfill
            \begin{subfigure}[t]{0.48\linewidth}
                \begin{tikzpicture}
                    \begin{axis}[
                        domain=0:1,
                        ymax=1,
                        xlabel={Input $x$},
                        ylabel={$f(x)$},
                        %samples=801
                                ]
                        \addplot[orange, mark=*] {sin(5*deg(x))};
                        \addplot[black, mark=*] {sin(10*deg(x))};
                        \legend{$\sin(5x)$,$\sin(10x)$,$\sin(50x)$}
                    \end{axis}
                \end{tikzpicture}
                \caption{Plot 2}
            \end{subfigure}

        \medskip
            \begin{subfigure}[t]{0.48\linewidth}
                \begin{tikzpicture}
                    \begin{loglogaxis}[
                    xmin=10, xmax=0.1e8,
                    ymin=1e-13, ymax=1e1,
                    xlabel={Number of Flops}, 
                    ylabel={Normalized MSE: $\log_{10} (e)$ },
                    %label style={font=\bfseries\boldmath},
                    %tick label style={font=\bfseries\boldmath},
                    scatter/classes={ a={mark=square*, blue}, b={mark=square*, red}, c={mark=square, black}, d={mark=triangle*, blue}, e={mark=triangle*, red},f={mark=triangle*, black},g={mark=x, black}, h={mark= diamond*, pink} },
                    ] 
                        \addplot[scatter, only marks,
                        scatter src=explicit symbolic]
                            table[meta=label] {
                                x     y      label
                                55.57063517556737 0.28272347338878956 a

                                };                        
                    \end{loglogaxis}
                \end{tikzpicture}
                \caption{Plot 3}
            \end{subfigure}
        \hfill
            \begin{subfigure}[t]{0.48\linewidth}
                \begin{tikzpicture}
                    \begin{axis}[
                        domain=0:1,
                        xlabel={Input $x$}, 
                        ylabel={$f(x)$},
                        ymin= 0, ymax=1e1,
                                ]
                        \addplot[orange, mark=*]  {e^x)};
                        \addplot[black, mark=*]  {e^(2*x))};
                        \legend{$\exp(x)$,$\exp(2x)$}
                    \end{axis}
                \end{tikzpicture}
                \caption{Plot 4}
            \end{subfigure}
    \caption{caption for all plots}
    \label{all_plots}
\end{figure}

\end{document}

Qrrbrbirlbel
  • 119,821
  • 1
    How you expect that they be aligned? So far they are left. Is it acceptable that they be right aligned (at second diagram in rows)? – Zarko Aug 05 '23 at 20:54
  • @Zarko , Yes, that's what I wish to do. For all the figures I want the ticks to be right aligned. (That is, to start from the 'y-axis') – Formal_this Aug 05 '23 at 22:18

1 Answers1

0

Edit:

  • From your comment follows, that you like to have all diagrams of equal size, vertical and horizontal centered - This you can obtain by define equal minimum height for xtick labels and equal text width for ytick in each figure column:
  • This you can get by playing with tick label style, xticklabel style˙and `yticklabel style as is now done in MWE below:
\documentclass[12pt, a4paper,
                parskip=half,
                toc=bibliography,
                numbers=noendperiod
               ]{scrbook}

\usepackage[hmargin={3.0cm, 2.5cm}, vmargin={2.5cm, 2.0cm}, includehead, includefoot ]{geometry}

\usepackage[UKenglish]{babel} \usepackage[T1]{fontenc}

\usepackage{scrlayer-scrpage} \usepackage{subcaption} \usepackage{caption}

\setkomafont{captionlabel}{\bfseries\rmfamily}

\usepackage[dvipsnames,table,xcdraw]{xcolor} \usepackage{pgfplots} \pgfplotsset{compat=1.18}

\begin{document} \begin{figure}[ht] \pgfplotsset{ width=\linewidth, height=0.9\linewidth, enlarge y limits=0.1, tick label style={font=\footnotesize}, xticklabel style={minimum height=3ex, anchor=north}, yticklabel style={text width=2em, align=right}, label style={inner sep=0pt, font=\footnotesize\bfseries\boldmath}, legend style = {font=\footnotesize} } \begin{subfigure}[t]{0.48\linewidth} \begin{tikzpicture} \begin{loglogaxis}[ xmin=10, xmax=0.1e8, ymin=1e-8, ymax=1e2, xlabel={Number of Flops}, ylabel={Normalized MSE: $\log_{10} (e)$ }, scatter/classes = { a={mark=square, blue}, b={mark=square, red}, c={mark=square, black}, d={mark=triangle, blue}, e={mark=triangle, red}, f={mark=triangle, black}, g={mark=x, black}, h={mark= diamond, pink} }, ] \addplot[scatter, only marks, scatter src=explicit symbolic] table[meta=label] { x y label 1320.9279232530525 0.9258769833615981 a }; \end{loglogaxis} \end{tikzpicture} \caption{Plot 1} \end{subfigure} \hfill \begin{subfigure}[t]{0.48\linewidth} \begin{tikzpicture} \begin{axis}[ yticklabel style={text width=1.7em}, domain=0:1, ymax=1, xlabel={Input $x$}, ylabel={$f(x)$}, ] \addplot[orange, mark=*] {sin(5deg(x))}; \addplot[black, mark=] {sin(10*deg(x))}; \legend{$\sin(5x)$,$\sin(10x)$,$\sin(50x)$} \end{axis} \end{tikzpicture} \caption{Plot 2} \end{subfigure}

\medskip

\begin{subfigure}[t]{0.48\linewidth} \begin{tikzpicture} \begin{loglogaxis}[ xmin=10, xmax=0.1e8, ymin=1e-13, ymax=1e1, xlabel={Number of Flops}, ylabel={Normalized MSE: $\log_{10} (e)$ }, scatter/classes = { a={mark=square, blue}, b={mark=square, red}, c={mark=square, black}, d={mark=triangle, blue}, e={mark=triangle, red}, f={mark=triangle, black}, g={mark=x, black}, h={mark= diamond, pink} }, ] \addplot[scatter, only marks, scatter src=explicit symbolic] table[meta=label] { x y label 55.57063517556737 0.28272347338878956 a }; \end{loglogaxis} \end{tikzpicture} \caption{Plot 3} \end{subfigure} \hfill \begin{subfigure}[t]{0.48\linewidth} \begin{tikzpicture} \begin{axis}[ yticklabel style={text width=1.7em}, domain=0:1, xlabel={Input $x$}, ylabel={$f(x)$}, ymin= 0, ymax=1e1, ] \addplot[orange, mark=*] {e^x)}; \addplot[black, mark=*] {e^(2*x))}; \legend{$\exp(x)$,$\exp(2x)$} \end{axis} \end{tikzpicture} \caption{Plot 4} \end{subfigure} \caption{caption for all plots} \label{all_plots} \end{figure} \end{document}

enter image description here

Zarko
  • 296,517
  • 1
    Yeah but that misaligns the the two figures of the right. isn't it? Now I am talking about the vertical alignment of the two figures on the right , fig (b) and fig (d).

    Also the y-lables of the figure (b) and figure (d) can be closer to the axis.

    – Formal_this Aug 06 '23 at 00:07
  • @Formal_this, see edited answer. It is based on my answer with similar question (which so far I didn't find), si your question is actually duplicate. – Zarko Aug 06 '23 at 04:50