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:


X,  Y,   Z,
A,  2,   3,
B,  3,   6,
C,  4,   nan,
D,  nan, nan,
E,  6,   nan,

\pgfplotstableread[col sep=comma,]{temp.csv}\datatable
    xticklabels from table={\datatable}{X},
    \addplot table [x expr=\coordindex, y={Y}] {\datatable};
    \addplot table [x expr=\coordindex, y={Z}] {\datatable};

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

So after fussing about this problem and posting this question, I discovered the answer. It is as simple as putting:


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.