# PGFPlots Missing column data, but show all x-values regardless

I have a data set where certain columns have missing data. I'd like to plot individual columns of this data on different plots with a consistently sized x-axis.

Here's an MWE:

\documentclass[]{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{filecontents}{temp.csv}
X,  Y,   Z,
A,  2,   3,
B,  3,   6,
C,  4,   nan,
D,  nan, nan,
E,  6,   nan,
\end{filecontents}

\begin{document}
\begin{tikzpicture},
\centering
\begin{axis}[
xtick={0,...,4},
xticklabels from table={\datatable}{X},
]
\addplot table [x expr=\coordindex, y={Y}] {\datatable};
\addplot table [x expr=\coordindex, y={Z}] {\datatable};
\end{axis}
\end{tikzpicture}
\end{document}


If you compile this document, you will see two lines for columns Y and Z. Now, if you comment out \addplot table [x expr=\coordindex, y={Y}] {\datatable};, the x-axis is reduced to the labels A and B, because column Z only contains values at those rows.

Is there a way to force a plot of only column Z to show all five labels on the x-axis?

• Have you tried adding unbounded coords=jump, to the options of axis? – user121799 Aug 8 '18 at 16:14
• I did try that, but it did not have any effect. – SteelAngel Aug 8 '18 at 16:18

xmin=0,

into the axis environment. I had assumed incorrectly that the xtick key would take care of the problem without having to put the limits in explicitly.