2

I have the following result:

enter image description here

but I need this result:

enter image description here

The code I used is the following.

\begin{figure}[H]
    \centering
    \begin{tabularx}{12cm}{c}
        \begin{tikzpicture}
        \begin{axis}[
            ybar,ymin=0,
            width=12cm, height=8cm,
            bar width=15pt,
            x tick label style={
                rotate=-90},
            major x tick style = transparent,
            ymajorgrids = true,
            xtick = data,
            scaled y ticks = false,
            symbolic x coords={4-Pa-Pr, 5-Pa-Pr, 6-Pa-Pr, 6-C-Pr, 6-M-Pr, 6-W-Pr, 7-Pa-Pr, 4-Pa-S, 5-Pa-S, 6-Pa-S, 6-C-S, 6-M-S, 6-W-S, 7-Pa-S},
            ymajorgrids]
            \addplot[fill=red!50] table[x=Sample,y=BD] {BulkDensity.dat};
        \end{axis}
        \end{tikzpicture}
    \end{tabularx}
    \caption{Bulk Density (g/cm\ap{3})}
    \label{fig:BD}
\end{figure}
Torbjørn T.
  • 206,688
Stefano
  • 1,038
  • see also http://tex.stackexchange.com/questions/209656/change-color-of-individual-bars-in-histogram-of-binomial-distribution or http://tex.stackexchange.com/questions/219213/tikz-addplot-fill-between-depending-on-sign – Marijn Oct 12 '15 at 15:19
  • You can combine the techniques in the links provided by Marijn, together with the key skip first n (see section "4.3.2 Reading Coordinates From Tables" of pgfplots manual) to plot the last part of the histogram in red. – LucaD Oct 12 '15 at 15:30
  • Not related but, why are you using tabularx in your example? – LucaD Oct 12 '15 at 15:32
  • @LucaD I don't know :) Actually is better to use tabular, isn't it? – Stefano Oct 12 '15 at 16:12
  • @stefano No, I think you don't need it nor any tabular environment, so I was asking if there was a specific reason. If not, I think you should not use it. – LucaD Oct 12 '15 at 16:21
  • could you post BulkDensity.dat? – cmhughes Oct 12 '15 at 17:50

0 Answers0