[Tex/LaTex] Force symbolic x coords

pgfplotstikz-pgf

My x-axis value disappears if the bar graph is not complete:

\begin{tikzpicture}
    \begin{axis}[
    every axis plot post/.style={/pgf/number format/fixed},
    ybar = 5pt,
    bar width=12pt,
    x=1.75cm,
    ymin = 1,
    %ymax = 1000,
    ymode = log,
    axis on top,
    xtick=data,
    enlarge x limits=0.2,
    symbolic x coords={100, 250, 500, 1000},
    %restrict y to domain*=0:1200, % Cut values off at 14
    visualization depends on=rawy\as\rawy, % Save the unclipped values
    after end axis/.code={ % Draw line indicating break
        \draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
    },
    nodes near coords={%
        \pgfmathprintnumber[sci, sci superscript, precision=2]{\rawy}% Print unclipped values
    },
    axis lines*=left,
    clip=false,
    ylabel={runtime [ms]},
    xlabel={image size [edge]},
    tick label style={font=\footnotesize},
    legend style={at={(0.5,-0.22)},
        anchor=north,legend columns=-1},
    ]    
    \addplot coordinates {(100, 340) (250, 5716) (500, 50669)};
    \addplot coordinates {(100, 21.25) (250, 331.97) (500, 2722) (1000,21877)};
    \addplot coordinates {(100, 15.77) (250, 158.15) (500, 1287) (1000,13224)};

    \legend{Conventional, Separated, Separated with SIMD}

    \end{axis}
    \end{tikzpicture}

I just can't see the value 1000 on the x-axis because there are only 3 values for one group

Best Answer

One minimal effort fix is to use xtick={100, 250, 500, 1000} instead of xtick=data.

\documentclass[border=3.14mm,tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
    every axis plot post/.style={/pgf/number format/fixed},
    ybar = 5pt,
    bar width=12pt,
    x=1.75cm,
    ymin = 1,
    %ymax = 1000,
    ymode = log,
    axis on top,
    %xtick=data,
    xtick={100, 250, 500, 1000},
    enlarge x limits=0.2,
    symbolic x coords={100, 250, 500, 1000},
    %restrict y to domain*=0:1200, % Cut values off at 14
    visualization depends on=rawy\as\rawy, % Save the unclipped values
    after end axis/.code={ % Draw line indicating break
        \draw [ultra thick, white, decoration={snake, amplitude=1pt}, decorate] (rel axis cs:0,1.05) -- (rel axis cs:1,1.05);
    },
    nodes near coords={%
        \pgfmathprintnumber[sci, sci superscript, precision=2]{\rawy}% Print unclipped values
    },
    axis lines*=left,
    clip=false,
    ylabel={runtime [ms]},
    xlabel={image size [edge]},
    tick label style={font=\footnotesize},
    legend style={at={(0.5,-0.22)},
        anchor=north,legend columns=-1},
    ]    
    \addplot coordinates {(100, 340) (250, 5716) (500, 50669)};
    \addplot coordinates {(100, 21.25) (250, 331.97) (500, 2722) (1000,21877)};
    \addplot coordinates {(100, 15.77) (250, 158.15) (500, 1287) (1000,13224)};

    \legend{Conventional, Separated, Separated with SIMD}

    \end{axis}
\end{tikzpicture}
\end{document}  

enter image description here