csv-2d-gaussian-multivarate-distributions.tex 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. % Thanks to Jake for helping me with this one:
  2. % http://tex.stackexchange.com/a/198531/5645
  3. \documentclass[varwidth=true, border=5pt]{article}
  4. \usepackage[active,tightpage]{preview}
  5. \usepackage[latin1]{inputenc}
  6. \usepackage{amsmath}
  7. \usepackage{pgfplots}
  8. \pgfplotsset{compat=1.10}
  9. \usepackage{tikz}
  10. \usetikzlibrary{arrows, positioning}
  11. \usepackage{helvet}
  12. \usepackage[eulergreek]{sansmath}
  13. \begin{document}
  14. \begin{preview}
  15. \begin{tikzpicture}
  16. \begin{axis}[
  17. clip mode=individual,
  18. width=13.4cm,
  19. height=10.0cm,
  20. % Grid
  21. grid = major,
  22. % size
  23. xmin= 40, % start the diagram at this x-coordinate
  24. xmax= 90, % end the diagram at this x-coordinate
  25. ymin= 0, % start the diagram at this y-coordinate
  26. ymax= 60, % end the diagram at this y-coordinate
  27. % Legende
  28. legend style={
  29. font=\large\sansmath\sffamily,
  30. at={(0.5,-0.18)},
  31. anchor=north,
  32. legend cell align=left,
  33. legend columns=-1,
  34. column sep=0.5cm
  35. },
  36. % Ticks
  37. tick align=inside,
  38. every axis/.append style={font=\large\sansmath\sffamily},
  39. minor tick style={thick},
  40. scaled y ticks = false,
  41. % Axis
  42. axis line style = {very thick,shorten <=-0.5\pgflinewidth},
  43. axis lines = middle,
  44. axis line style = very thick,
  45. xlabel=Gesamtausgaben,
  46. x label style={at={(axis description cs:0.5,-0.05)},
  47. anchor=north,
  48. font=\boldmath\sansmath\sffamily\Large},
  49. ylabel=Luxusausgaben,
  50. y label style={at={(axis description cs:-0.05,0.5)},
  51. anchor=south,
  52. rotate=90,
  53. font=\boldmath\sansmath\sffamily\Large}
  54. ]
  55. \addplot[
  56. scatter,
  57. only marks,
  58. point meta=explicit symbolic,
  59. scatter/classes={
  60. a={mark=x,red!90!black,fill opacity=0.2},%
  61. b={mark=x,cyan!50!black,fill opacity=0.2}},
  62. ]
  63. table[col sep=comma, meta=label] {data.csv};
  64. \addplot[domain=40:90, thick, dashed, black!60!white,samples=10] {0.5*x-2.5};
  65. \filldraw [fill=red!30!white, draw=black, thick] (axis cs:70,40) circle [radius=5pt];
  66. \filldraw [fill=cyan!30!white, draw=black, thick] (axis cs:60,20) circle [radius=5pt];
  67. \filldraw [fill=green!70!black, draw=black, thick] (axis cs:65,35) circle [radius=5pt] node [label={[inner sep=1pt, fill=white,text=black, fill opacity=0.75, text opacity=1]above left:$(65, 35)$}] {};
  68. % \addlegendentry{Gruppe 1}
  69. % \addlegendentry{Gruppe 2}
  70. \end{axis}
  71. \end{tikzpicture}
  72. \end{preview}
  73. \end{document}