LaTeX forum ⇒ Graphics, Figures & TablesChange the formatting of individual bars

Information and discussion about graphics, figures & tables in LaTeX documents.
jo8x
Posts: 1
Joined: Tue Jul 23, 2019 3:56 pm

Change the formatting of individual bars

Postby jo8x » Tue Jul 23, 2019 4:46 pm

Hi there,

I am new here and have trouble to find a solution to the follwing problem with pgfplots:
So far I managed to typeset a bar plot as follows:

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepackage{xcolor}
\pgfplotsset{width=12.8cm,compat=1.15}
\definecolor{red}{HTML}{B61231}
\definecolor{blue}{HTML}{1262b9}
\definecolor{green}{HTML}{0f720f}
\definecolor{ochre}{HTML}{C38A2A}

\begin{document}

\begin{tikzpicture}[]
\begin{axis}[
ybar=5pt,
bar width=12pt,
enlarge x limits=0.08,
enlarge y limits=0.01,
xtick style={draw=none},
legend style={at={(0.5,-0.07)},
anchor=north,legend columns=-1},
ylabel={Number / Unit},
symbolic x coords={RefMat1,RefMat2,Mat1,Mat2,Mat3,Mat4},
xtick=data,
xtick align=inside,
xticklabel style={text width=2cm,
font=\normalsize,
align=center,
},
]

%Condition1
\addplot[black,fill=blue,error bars/.cd,y dir=both,y explicit,]
coordinates
{
(RefMat1,6) +-(2,2)
(RefMat2,65) +-(3,3)
(Mat1,243) +-(29,29)
(Mat2,248) +-(57,57)
(Mat3,169) +-(30,30)
(Mat4,80) +-(12,12)
};

%Condition2
\addplot[black,fill=red,error bars/.cd,y dir=both,y explicit,]
coordinates
{
(RefMat1,89) +-(17,17)
(RefMat2,194) +-(61,61)
(Mat1,238) +-(13,13)
(Mat2,275) +-(43,43)
(Mat3,283) +-(47,47)
(Mat4,229) +-(18,18)
};

\end{axis}
\end{tikzpicture}
\end{document}


I am quite happy with it, except that I would like to format the RefMat1 and RefMat2 bars with a pattern. Is there an easy way to do this?

Cheers and thank you very much for you help!
Attachments
test1.PNG
test1.PNG (11.38 KiB) Viewed 95 times

Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 7 guests