Building a bar chart
A classical way to display categories with corresponding values is a bar chart. It consists of rectangular bars that are proportional to the represented values. The primary purpose is to compare those values visually.
We can use vertical or horizontal bars.
How to do it...
We will use the pgfplots package. It’s for natively plotting in LaTeX with a convenient user interface. We will use it to produce a horizontal bar chart.
Follow these steps:
- Start with a document class:
\documentclass{article}
- Load the pgfplots package:
\usepackage{pgfplots} \pgfplotsset{width=7cm,compat=1.18}
- Begin the document:
\begin{document}
- Begin a TikZ picture, which will be the container for the plot:
\begin{tikzpicture}
- Open an axis environment:
\begin{axis}
- Give options to the axis:
[ title = Contributions per category ...