Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. cellcolor{black!##1}
  2.  
  3. documentclass{article}
  4. usepackage[table]{xcolor}
  5. usepackage{pgfplotstable}
  6.  
  7. pgfplotstableset{
  8. color cells/.style={
  9. col sep=comma,
  10. string type,
  11. postproc cell content/.code={%
  12. pgfkeysalso{@cell content=rule{0cm}{2.4ex}cellcolor{black!##1}pgfmathtruncatemacronumber{##1}ifnumnumber>50color{white}fi##1}%
  13. },
  14. columns/x/.style={
  15. column name={},
  16. postproc cell content/.code={}
  17. }
  18. }
  19. }
  20.  
  21. begin{document}
  22. begin{table}caption{Correlation or something}
  23. centering
  24. pgfplotstabletypeset[color cells]{
  25. x,a,b,c,d
  26. a,90,10.5,0,0
  27. b,0,80,10,10
  28. c,0,0,95,5
  29. d,0,10,5,85
  30. }
  31. end{table}
  32. end{document}
  33.  
  34. documentclass[border=5mm]{standalone}
  35. usepackage{pgfplotstable,colortbl}
  36. pgfplotsset{compat=1.12}
  37.  
  38. pgfplotstableset{
  39. /color cells/min/.initial=0,
  40. /color cells/max/.initial=1000,
  41. /color cells/textcolor/.initial=,
  42. color cells/.style={
  43. postproc cell content/.append code={%
  44. pgfkeys{/color cells/.cd,#1}%
  45. pgfkeysgetvalue{/pgfplots/table/@preprocessed cell content}value%
  46. ifxvalueempty%
  47. else%
  48. pgfmathfloatparsenumber{value}pgfmathfloattofixed{pgfmathresult}%
  49. letvalue=pgfmathresult%
  50. pgfplotscolormapaccess%
  51. [pgfkeysvalueof{/color cells/min}:pgfkeysvalueof{/color cells/max}]%
  52. {value}{pgfkeysvalueof{/pgfplots/colormap name}}%
  53. pgfkeysgetvalue{/pgfplots/table/@cell content}typesetvalue%
  54. pgfkeysgetvalue{/color cells/textcolor}textcolorvalue%
  55. toks0=expandafter{typesetvalue}%
  56. edeftemp{noexpandpgfkeyssetvalue{/pgfplots/table/@cell content}{%
  57. noexpandcellcolor[rgb]{pgfmathresult}%
  58. noexpanddefinecolor{mapped color}{rgb}{pgfmathresult}%
  59. ifxtextcolorvalueemptyelsenoexpandcolor{textcolorvalue}fi%
  60. thetoks0%
  61. }%
  62. }%
  63. temp%
  64. fi%
  65. }%
  66. }%
  67. }%
  68.  
  69. begin{document}
  70. pgfplotstabletypeset[col sep=comma,
  71. /color cells/max=100,
  72. /color cells/min=0,
  73. /color cells/textcolor=white,
  74. columns/a/.style={color cells},
  75. columns/b/.style={color cells},
  76. columns/c/.style={color cells},
  77. columns/d/.style={color cells},
  78. columns/x/.style={string type},
  79. /pgfplots/colormap/blackwhite,
  80. ]{
  81. x,a,b,c,d
  82. a,90,10.5,0,0
  83. b,0,80,10,10
  84. c,0,0,95,5
  85. d,0,10,5,85
  86. }
  87. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement