Diagramas de barras en LaTeX
Esta seccion esta dedicada a explicar como crear y personalizar un diagrama de barras con variables cuantitativas y cualitativas.
\documentclass{article}
\usepackage[papersize={14cm,10cm}]{geometry}
\geometry{
left=10mm,
top=20mm,
}
\usepackage{tikz,xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\definecolor{azul}{HTML}{006BBB}
\definecolor{celeste}{HTML}{30A0E0}
\definecolor{mostaza}{HTML}{FFC872}
\definecolor{crema}{HTML}{FFE3B3}
\definecolor{roja}{HTML}{DD4470}
\pagestyle{empty}
\begin{document}
%\pagecolor{green}
\begin{tikzpicture}
\begin{axis}[]
\addplot[ybar] plot coordinates
{(2014,5) (2015,3) (2016,2) (2017,4) (2018,1) (2019,2)};
\addplot plot coordinates
{(2014,5) (2015,3) (2016,2) (2017,4) (2018,1) (2019,2)};
\end{axis}
\end{tikzpicture}
% segundo
\begin{tikzpicture}
\begin{axis}[ybar,
azul,
x tick label style={/pgf/number format/1000 sep=},
enlarge x limits=0.2,
width=12cm, height=7cm,
axis background/.style={fill=crema},
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1}
]
\addplot[azul,fill=azul] plot coordinates
{(2014,5) (2015,3) (2016,2) (2017,4) (2018,1) (2019,2)};
\addplot[roja, fill=roja] plot coordinates
{(2014,2) (2015,5) (2016,8) (2017,2) (2018,4) (2019,2)};
\addplot[mostaza,fill=mostaza] plot coordinates
{(2014,4) (2015,2) (2016,4) (2017,5) (2018,6) (2019,5)};
\legend{Categoria 1,Categoria 2,Categoria 3}
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
azul,
ybar,
x tick label style={/pgf/number format/1000 sep=},
enlarge x limits=0.2,
axis background/.style={fill=crema},
width=12cm, height=7cm,
ylabel=Frecuencia,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
symbolic x coords={Argentina, Bolivia, Colombia, Peru},
xtick=data,bar width=2cm,]
\addplot[roja,fill=roja] plot coordinates
{(Colombia,5) (Bolivia,3) (Argentina,2) (Peru,4)};
\end{axis}
\end{tikzpicture}
\end{document}