A bar chart can be used for comparing values. Here we create a horizontal bar chart.
The pgfplots package provides an easy way. In this example, I reduced axis data to focus on the values. So I do not show x-axis and y-axis, or axis ticks.
Edit and compile if you like:
% Bar charts
% Author: Stefan Kottwitz
% https://www.packtpub.com/hardware-and-creative/latex-cookbook
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[title = Contributions per category
at LaTeX-Community.org,
xbar,
y axis line style = { opacity = 0 },
axis x line = none,
tickwidth = 0pt,
enlarge y limits = 0.2,
enlarge x limits = 0.02,
symbolic y coords = {LaTeX, Tools, Distributions, Editors},
nodes near coords,
]
\addplot coordinates { (57727,LaTeX) (5672,Tools)
(2193,Distributions) (11106,Editors) };
\addplot coordinates { (14320,LaTeX) (1615,Tools)
(560,Distributions) (3075,Editors) };
\legend{Topics, Posts}
\end{axis}
\end{tikzpicture}
\end{document}Click to download: bar-chart.tex • bar-chart.pdfOpen in Overleaf: bar-chart.tex
See also: Original Source by Stefan Kottwitz
Note: The copyright belongs to the blog author and the blog. For the license, please see the linked original source blog.
Leave a Reply
You must be logged in to post a comment.