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