bar-chart-grouping.tex 943 B

123456789101112131415161718192021222324252627282930
  1. % Source: http://tex.stackexchange.com/a/69234/5645
  2. \documentclass[varwidth=true, border=2pt]{standalone}
  3. \usepackage{pgfplots}
  4. \begin{document}
  5. \begin{tikzpicture}
  6. \begin{axis}[
  7. ybar,
  8. ylabel={vaule/weight},
  9. xlabel={items},
  10. legend style={at={(0.5,-0.15)},
  11. anchor=north,legend columns=-1},
  12. width=0.8*\textwidth,
  13. height=9cm,
  14. bar width=7pt,
  15. symbolic x coords={$x_1$,$x_2$,$x_3$,$x_4$,$x_5$},
  16. xtick=data,
  17. %nodes near coords,
  18. %nodes near coords align={vertical},
  19. ]
  20. \addplot
  21. coordinates {($x_1$,96000) ($x_2$,126000) ($x_3$,115000) ($x_4$,125000) ($x_5$,123000)};
  22. \addplot
  23. coordinates {($x_1$,27) ($x_2$,21) ($x_3$,27) ($x_4$,15) ($x_5$,19)};
  24. \legend{value, weight}
  25. \end{axis}
  26. \end{tikzpicture}
  27. \end{document}