bar-chart-military-budget.tex 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage{pgfplots}
  5. \usepackage{tikz}
  6. \usepackage{helvet}
  7. \usepackage[eulergreek]{sansmath}
  8. % Sans serif fonts do not look as nice as serif fonts,
  9. % but they are much easier to read when the image is small
  10. \pgfplotsset{
  11. tick label style = {font=\sansmath\sffamily},
  12. every axis label = {font=\sansmath\sffamily},
  13. legend style = {font=\sansmath\sffamily},
  14. label style = {font=\sansmath\sffamily}
  15. }
  16. \begin{document}
  17. \begin{preview}
  18. \begin{tikzpicture}
  19. \begin{axis}[
  20. title = US military budget,
  21. % xlabel = Year,
  22. ylabel = In constant (2010) billion US\$,
  23. % Display option
  24. width = 12cm,
  25. height = 10cm,
  26. ymin = 340,
  27. ymax = 760,
  28. xmin = 1987,
  29. xmax = 2011.9,
  30. % Configuration
  31. title style = {font=\bfseries},
  32. x tick label style = {/pgf/number format/1000 sep=,
  33. inner sep=0pt,
  34. anchor=north east,
  35. rotate=45 },
  36. legend style = {at={(0.5,-0.15)},
  37. anchor = north,legend columns=-1},
  38. ybar = 5pt, % configures ‘bar shift’
  39. bar width = 9pt,
  40. nodes near coords,
  41. every node near coord/.append style = {rotate=90, anchor=west, font=\small\sansmath\sffamily},
  42. point meta = y, % the displayed number
  43. ]
  44. \addplot
  45. coordinates {(1988, 540.415) (1989, 534.906) (1990, 510.998)
  46. (1991, 448.806) (1992, 474.215) (1993, 449.281) (1994, 421.917)
  47. (1995, 399.043) (1996, 377.342) (1997, 375.375) (1998, 366.918)
  48. (1999, 367.822) (2000, 382.061) (2001, 385.142) (2002, 432.452)
  49. (2003, 492.200) (2004, 536.459) (2005, 562.039) (2006, 570.769)
  50. (2007, 585.749) (2008, 629.095) (2009, 679.574) (2010, 698.281)
  51. (2011, 689.591) };
  52. \end{axis}
  53. \end{tikzpicture}
  54. \end{preview}
  55. \end{document}