countable-sets.tex 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. \documentclass{standalone}
  2. \usepackage{pgfplots}
  3. \usepackage{sansmath} % for sans serif math
  4. %%%<
  5. % The data files, written on the first run.
  6. \begin{filecontents}{function.data}
  7. # n m
  8. 1 1
  9. 1 2
  10. 2 1
  11. 1 3
  12. 2 2
  13. 3 1
  14. 1 4
  15. 2 3
  16. 3 2
  17. 4 1
  18. 1 5
  19. 2 4
  20. 3 3
  21. 4 2
  22. 5 1
  23. \end{filecontents}
  24. \begin{document}
  25. \begin{tikzpicture}
  26. \begin{axis}[
  27. compat=newest, % for better label placement
  28. font=\sansmath\sffamily, % math and normal text in sans serif
  29. xlabel=n, ylabel=m, % the label texts
  30. xmin=0, ymin=0, % axis origin
  31. enlarge y limits=false, % don't enlarge the y axis beyond the data range
  32. enlarge x limits={upper,abs=0.02}, % enlarge x axis slightly to make sure the last tick mark is drawn completely
  33. axis lines*=left, % only draw the left axis lines, not a box
  34. unit vector ratio*={1 1 1}, % equal axis scaling. "*" to make sure the axes can only be reduced in size, not enlarged
  35. width=6cm, % set the overall width of the plot
  36. try min ticks=5, % adjusts how many ticks are printed
  37. tick align=center, % tick marks centered on the axes
  38. legend style={
  39. draw=none, % no frame around axes
  40. at={(1,1)}, % place at upper right of plot
  41. anchor=north % use upper middle edge of legend for alignment
  42. },
  43. ]
  44. \addplot [
  45. mark=square*, mark size=0.5em, % square, filled ("*"), radius of 0.5em
  46. nodes near coords={
  47. \pgfmathparse{int(\coordindex+1)}
  48. \pgfmathresult
  49. }, % print labels on each data point, using `\coordindex` (the data point counter) increased by 1
  50. every node near coord/.style={
  51. font=\scriptsize\sffamily\bfseries, % smaller text size, bold for the data point labels
  52. text=white,
  53. anchor=center % center the labels on the plot marks
  54. }
  55. ] table {function.data};
  56. \addlegendentry{f(m,n)}
  57. \end{axis}
  58. \end{tikzpicture}
  59. \end{document}