0

This is in relation to my previous question here:How to colour barplot according to groups in table

to which, it was suggested that I refer to another question here: Colors and legend in groupplots/barplot

Briefly, I have data that can be categorised as animal or plant origin. I want the barplot of the animal values to be red and those of plants to be green (or blue, whichever).

I tried to restructure my datatable to implement the coding style in the suggested link, but to no avail. I am continuously getting errors. I am new to LaTeX and I have referred to the manual as much as I can. Please help me solve this problem.

Here is my minimal code that gives me an error:

\documentclass{beamer} \begin{document} \begin{frame} \begin{tikzpicture} \pgfplotstableread[row sep=\\,col sep=&]{ Goat milk & Buffalo milk & Buffalo meat & Eggs & Cereals & Vegetables \\ 69.8 & 19.0 & 19.7 & 5 & 1.6 & 0.3 \\ }\coeqtable \begin{tikzpicture} \only<5->{ \begin{axis}[ xbar, % enlarge x limits=0.15, width = 5cm, %enlarge x limits=0.3, ytick=data, xmin=0, xlabel={CO\textsubscript{2~eq.}/kg\textsubscript{protein}}, xmajorgrids=true, xminorgrids=true, grid style=dashed, label style = {font=\scriptsize}, yticklabel style={xshift=0.6ex, text width=1.7cm, font=\scriptsize, align=right}, ticklabel style = {font=\scriptsize}, ] \addplot [fill=red!60, draw=red] table [x expr=\coordindex, y=Goat milk] {\coeqtable}; %Will manually enter colour for each bar \end{axis} \end{tikzpicture} \end{frame} \end{document} 
1
  • It is unclear to me how the data should be represented. Isn't 69.8 a value that is associated to Buffalo Milk? I is always better to have a fixes number of colums and a variable number or rows instead of the other way around. See your other question which seems to be very similar anyways. You can also add another column then that identifies the group of the items (such as meat or vegetable). Commented May 4 at 15:02

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.