TeX - LaTeX Asked by forecaster on March 29, 2021
I’m new to LaTeX. I’m trying to create a bar plot with beamer document class. Here is what I need:
Here is what I get in LaTeX:
Please see below for MWE:
Here are my questions:
documentclass{beamer}
setbeamertemplate{navigation symbols}{}
usetheme{Boadilla}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
begin{document}
begin{frame}
begin{figure}
centering
begin{tikzpicture}
begin{axis}[ybar=25pt,ymin=0,ymax=150,]
addplot[ybar,fill=blue, area legend] coordinates {(Rat,40)};
addplot[ybar,fill=red, area legend] coordinates {(Hippopotamus,146)};
end{axis}
end{tikzpicture}
end{figure}
end{frame}
end{document}
Welcome to TeX.SE. This follows: PGFPLOTS - Create Bar plot with bars in different colors. See the code for the various changes.
documentclass{beamer}
setbeamertemplate{navigation symbols}{}
usetheme{Boadilla}
usepackage{pgfplots}
pgfplotsset{width=7cm,compat=1.8}
begin{document}
begin{frame}
begin{figure}
centering
begin{tikzpicture}
begin{axis}[
ybar,
xmin=0.5,xmax=2.5, %<-- added
ymin=0,
ymax=150,
area legend,
xtick={1,2}, % <-- added
xticklabels={Rat,Hippopotamus}, % <-- added
every axis plot/.append style={ % <-- added
bar width=.5,
bar shift=0pt,
fill}
]
addplot[fill=blue] coordinates {(1,40)};
addplot[fill=red] coordinates {(2,146)};
end{axis}
end{tikzpicture}
end{figure}
end{frame}
end{document}
Correct answer by Ross on March 29, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP