Using pgfplotstable I plot a table of data which has more decimal places than 1, however, I just want to display 1 decimal place so I am using precision=1
, which works well, except for in cases where the decimal place is a 0. It does not display 14.0 but only 14 although I said precision=1
.
Here is a MWE:
\documentclass{article}
\usepackage{mwe}
\usepackage{tikz,pgfplotstable}
\pgfplotsset{compat=newest}
\begin{document}
This is what I get from pgfplotstable:
\pgfplotstabletypeset[col sep=comma, row sep=\\,precision=1,column type={r}
]{
a, b, c\\
17.82, 7.51, 7.62\\
17.02, 14.02, 12.01\\
19.43, 6.03, 4.52\\
18.03, 7.41, 6.81\\
}
This is what I want:
\begin{tabular}{rrr}
a& b& c\\
17.8& 7.5& 7.6\\
17.0&14.0& 12.0\\
19.4& 6.0& 4.5\\
18.0& 7.4& 6.8\\
\end{tabular}
\end{document}
How to tell pgfplotstable to print the .0?
Best Answer
tikz-pgf, pgfplots, and pgfplotstable use the same number-printing system and one can find a elaborated explanation in both tikz-pgf and pgfplotstable's documents.
/pgf/number format/fixed
rounds the number to a fixed number of digits after the period, discarding any trailing zeros./pgf/number format/fixed zerofill={⟨boolean⟩}
enables or disables zero filling for any number drawn in fixed point format./pgf/number format/sci
configures\pgfmathprintnumber
to display numbers in scientific format, that means sign, mantissa and exponent (base 10). The mantissa is rounded to the desired precision (or sci precision, see below)./pgf/number format/sci zerofill={⟨boolean⟩}
enables or disables zero filling for any number drawn in scientific format./pgf/number format/zerofill={⟨boolean⟩}
sets bothfixed zerofill
andsci zerofill
at once.Read the document for more options.
For your case, writing
will do the job.