Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cellcolor{black!##1}
- documentclass{article}
- usepackage[table]{xcolor}
- usepackage{pgfplotstable}
- pgfplotstableset{
- color cells/.style={
- col sep=comma,
- string type,
- postproc cell content/.code={%
- pgfkeysalso{@cell content=rule{0cm}{2.4ex}cellcolor{black!##1}pgfmathtruncatemacronumber{##1}ifnumnumber>50color{white}fi##1}%
- },
- columns/x/.style={
- column name={},
- postproc cell content/.code={}
- }
- }
- }
- begin{document}
- begin{table}caption{Correlation or something}
- centering
- pgfplotstabletypeset[color cells]{
- x,a,b,c,d
- a,90,10.5,0,0
- b,0,80,10,10
- c,0,0,95,5
- d,0,10,5,85
- }
- end{table}
- end{document}
- documentclass[border=5mm]{standalone}
- usepackage{pgfplotstable,colortbl}
- pgfplotsset{compat=1.12}
- pgfplotstableset{
- /color cells/min/.initial=0,
- /color cells/max/.initial=1000,
- /color cells/textcolor/.initial=,
- color cells/.style={
- postproc cell content/.append code={%
- pgfkeys{/color cells/.cd,#1}%
- pgfkeysgetvalue{/pgfplots/table/@preprocessed cell content}value%
- ifxvalueempty%
- else%
- pgfmathfloatparsenumber{value}pgfmathfloattofixed{pgfmathresult}%
- letvalue=pgfmathresult%
- pgfplotscolormapaccess%
- [pgfkeysvalueof{/color cells/min}:pgfkeysvalueof{/color cells/max}]%
- {value}{pgfkeysvalueof{/pgfplots/colormap name}}%
- pgfkeysgetvalue{/pgfplots/table/@cell content}typesetvalue%
- pgfkeysgetvalue{/color cells/textcolor}textcolorvalue%
- toks0=expandafter{typesetvalue}%
- edeftemp{noexpandpgfkeyssetvalue{/pgfplots/table/@cell content}{%
- noexpandcellcolor[rgb]{pgfmathresult}%
- noexpanddefinecolor{mapped color}{rgb}{pgfmathresult}%
- ifxtextcolorvalueemptyelsenoexpandcolor{textcolorvalue}fi%
- thetoks0%
- }%
- }%
- temp%
- fi%
- }%
- }%
- }%
- begin{document}
- pgfplotstabletypeset[col sep=comma,
- /color cells/max=100,
- /color cells/min=0,
- /color cells/textcolor=white,
- columns/a/.style={color cells},
- columns/b/.style={color cells},
- columns/c/.style={color cells},
- columns/d/.style={color cells},
- columns/x/.style={string type},
- /pgfplots/colormap/blackwhite,
- ]{
- x,a,b,c,d
- a,90,10.5,0,0
- b,0,80,10,10
- c,0,0,95,5
- d,0,10,5,85
- }
- end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement