Latex Bar Plot
I have the data stored on the 2024-10-26_game_count.csv file:
We can make the bar plot using:
-
We need the
pgfplots
andpgfplotstable
packages. We must indicate the pgfplots version with\pgfplotsset{compat=newest}
. -
With
\pgfplotstableread
we indicate how to read the file, using commas as separation, and we define the data as \datatable. -
To make the plot a bar plot, we use the
ybar
option of the axis. -
With
xticklabels from table = {\datatable}{Engine}
we configure the tick labels to be the same as the first column. -
xtick = data
makes one tick for each data we have. Without this, pgfplots will reduce the number of ticks if there is much data. -
With
xticklabel style={rotate=90}
we rotate the tick labels 90 degrees so they aren’t on top of each other. -
Finally, we create the plot with
\addplot table[x expr=\coordindex,y=Steam] {\datatable};
. We make the point x correspond to the coordinate index and we select the point y from the second column with header “Steam”.
Here’s the result: