I am having a real hard time trying to format a simple numeric table with PGFPlotsTable
. I have tried tons of combinations of TeX.SO
solutions, I just cannot get any working result.
The table looks like the following:
0.xy;0.00;0.01;0.02;0.03;0.04;0.05;0.06;0.07;0.08;0.09
0.00;-1.1;-0.5;-0.326;-0.3;-0.2;-0.1;0.0;0.0;0.0;0.1
0.10;0.1;0.1;0.1;0.2;0.2;0.2;0.2;0.2;0.2;0.2
0.20;0.2;0.3;0.3;0.3;0.3;0.3;0.3;0.3;0.3;0.3
0.30;0.3;0.3;0.3;0.3;0.4;0.4;0.4;0.4;0.4;0.4
0.40;0.4;0.4;0.4;0.4;0.4;0.4;0.4;0.4;0.4;0.4
0.50;0.4;0.4;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5
0.60;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5;0.5
0.70;0.5;0.6;0.6;0.6;0.6;0.6;0.6;0.6;0.6;0.6
0.80;0.6;0.7;0.7;0.7;0.7;0.7;0.7;0.7;0.8;0.8
0.90;0.8;0.8;0.9;0.9;1.0;1.1;1.2;1.4;1.7;1.9
This is a 11x11
matrix (a percentiles table). [Updated: The first cell is empty] The first cell is a label, and all others cells are guaranteed to be numeric. I would like to have the first row and the first column in bold font series
and using the following style: fixed, zerofill, precision=2
. The other numbers must be left as this.
As far as I have understood the PGFPlotsTable
mechanism:
- styles are defined by columns and can be altered cell by cell;
- header/row styles does not care about
fixed
andprecision
keys.
Are those statements right?
I also had strange behaviour modification when I fill the first cell with text or with a number, then my styles apply differently. I have tried to treat the first line as a header or as a simple row.
Is what I ask possible? If so, how do I achieve it?
Update 1: Here you will find my MNWE (Minimal Non Working Example), this is the best I could achieve and it does not do the trick
\pgfplotstabletypeset[
col sep=semicolon,1000 sep={},font=\footnotesize,dec sep align,fonts by sign={}{\color{red}},
every head row/.style={output empty row},
every first row/.style={fixed,zerofill,precision=2},
every first column/.style={fixed,zerofill,precision=2}
]{p.csv}
I do not understand why my first row is in scientific representation. And I could not set bold format neither for the column, nor for the row.
Update 2: Going deeper, I have tried many things and I am just surprised how a apparently simple formatting can be so tricky. I finally found how to access a single cell, but I cannot get a proper result when trying to format it.
\pgfplotstabletypeset[col sep=semicolon,
header=false,col sep=semicolon,1000 sep={},font=\footnotesize,
fixed,dec sep align,fonts by sign={}{\color{red}},
every head row/.style={output empty row},
every first row/.style={before row=\toprule},
every last row/.style={after row=\bottomrule},
columns/0/.style={zerofill, precision=2},
every row 0 column 1/.style={zerofill, precision=2},
every row 6 column 1/.style={postproc cell content/.append style={@cell content/.add={x}{y}}}
]{p.csv}
This MNWE outputs xx0yy.xx4yy
to the cell(6,1)
. It looks like the function add
is called twice on the integer part and then twice on the decimal part of my number (WTH, this explains why my outputs are so difficult to understand). Is it a bug? If not, how this behaviour can be explained?
It is impossible to make it bold using /.add{\bf}{}
as stated in the manual, but it is if I add column type=r
at the very top level (which leads to right aligned columns instead of decimal aligned columns).
I have used content={\textbf{##1}}
instead of /.add{\bf}{}
(removing or not the append
keyword) it outputs an unexpected 0<space>
before the real cell content (looks like a phantom of the integer part).
I have tried to remove style options, it does not help. It is the third time I read the 70-pages manual, and I just cannot make it work. What am I missing? How could this be so difficult?
Update 3: Still working on my table, here a MWE that achieve most of my goals.
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{pgfplotstable}
\begin{document}
\begin{table}[!ht]
\centering
\pgfplotstabletypeset[
col sep=semicolon,
header=has colnames,
columns/0.xy/.style={column name={},column type=r,string type,postproc cell content/.append style={@cell content={\textbf{##1}}}},
every head row/.style={before row=\toprule},
every last row/.style={after row=\bottomrule},
columns/0.00/.style={dec sep align},
columns/0.01/.style={dec sep align},
columns/0.02/.style={dec sep align},
columns/0.03/.style={dec sep align},
columns/0.04/.style={dec sep align},
columns/0.05/.style={dec sep align},
columns/0.06/.style={dec sep align},
columns/0.07/.style={dec sep align},
columns/0.08/.style={dec sep align},
columns/0.09/.style={dec sep align}
]{./media/data2.csv}
\end{table}
\end{document}
I cannot format header in bold, and alignment of header is somehow filthy. When a tried to set dec sep align
at the table style level and reset styles
at the first column level, I get compilation error, so I have to impose styles column by column.
How do I format header in bold?
How do I impose numeric style
to every columns except the first which is string type
?
I think I have showed some effort to solve my problem. I just get no answer to my post even after starting a bounty. Is my request unfeasible?