Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. \documentclass[a4paper]{article}
  2. \usepackage{tikz}
  3.  
  4. \begin{document}
  5. \newcommand{\plotbars}[1]
  6. {
  7. \begin{tikzpicture}
  8. \newcounter{length}
  9. \foreach \n [count=\k] in #1 {
  10. \stepcounter{length}
  11. \foreach \h in {1,...,\n} {
  12. \draw (\k * 2,\h) rectangle (\k * 2 + 1,\h + 1);
  13. }
  14. \node[draw] at (\k * 2 + 0.5, \n + 1.5) {\n};
  15. \node at (\k * 2 + 0.5, 0) {\k};
  16. }
  17. \draw (1,0.5) -- (\value{length} * 2 + 2, 0.5);
  18. \end{tikzpicture}
  19. }
  20.  
  21. \begin{figure}
  22. \plotbars{{1,2,3,4,5}}
  23. \caption{Barchart 1}
  24. \end{figure}
  25. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement