Skip to content

Instantly share code, notes, and snippets.

@rohit-gupta
Created December 4, 2017 07:58
Show Gist options
  • Save rohit-gupta/cea92ea5aea236937a27a8b690b4ed8d to your computer and use it in GitHub Desktop.
Save rohit-gupta/cea92ea5aea236937a27a8b690b4ed8d to your computer and use it in GitHub Desktop.
Simple categorical barchart in LaTex
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}
[ title = Number of videos in each category in MSR-VTT,
xbar,
y axis line style = { opacity = 0 },
axis x line = none,
tickwidth = 0pt,
y=-0.5cm,
bar width=0.3cm,
enlarge y limits={abs=0.45cm},
% enlarge y limits = 0.04,
% enlarge x limits = 0.1,
symbolic y coords = {sports/actions, movie/comedy, vehicles/autos, music, food/drink, animals/pets, howto, kids/family, news/events/politics, beauty/fashion, gaming, science/technology, cooking, tv shows, animation, education, travel, people, advertisement, documentary},
ytick = {sports/actions, movie/comedy, vehicles/autos, music, food/drink, animals/pets, howto, kids/family, news/events/politics, beauty/fashion, gaming, science/technology, cooking, tv shows, animation, education, travel, people, advertisement, documentary},
nodes near coords
]
\addplot coordinates { (784,sports/actions) (718,movie/comedy)
(571,vehicles/autos) (507,music)
(458,food/drink) (443,animals/pets)
(403,howto) (387,kids/family)
(355,news/events/politics) (341,beauty/fashion)
(332,gaming) (246,science/technology)
(232,cooking) (222,tv shows)
(221,animation) (200,education)
(188,travel) (173,people)
(117,advertisement) (112,documentary)};
\end{axis}
\end{tikzpicture}
\caption{Number of videos in each category in MSR-VTT}
\label{fig:msr_categories}
\end{figure}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment