4

How do I replace the blue backgrounds as indicated in the picture with a diagonal and grid pattern respectively?

I currently can't find a neat solution for my kind of graph.

Code

\begin{tikzpicture}
    \begin{axis}[
        ybar,
        bar width=1.0cm,
        enlargelimits=0.75,
        width=7.5cm, 
        height=6cm,
        xlabel={Predictive models}, ylabel style={align=center},
        ylabel={Predicitve accuracy (\%)},
        symbolic x coords={ensemble voting, lung cancer calculator},
        xtick=data, 
        xticklabel style={text width=2cm, align=center}
    ]
    \addplot coordinates {
        (lung cancer calculator,91.2)
        (ensemble voting,91.4)
    };
    \end{axis}
\end{tikzpicture}

Output

output image

1 Answers1

3

You can use TikZ drawing options in \addplot options.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usetikzlibrary{patterns}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[
        ybar,
        bar width=1.0cm,
        enlargelimits=0.75,
        width=7.5cm, 
        height=6cm,
        xlabel={Predictive models}, ylabel style={align=center},
        ylabel={Predicitve accuracy (\%)},
        symbolic x coords={ensemble voting, lung cancer calculator},
        xtick=data, 
        xticklabel style={text width=2cm, align=center}
    ]
    \addplot[pattern=crosshatch] coordinates {
        (lung cancer calculator,91.2)
        (ensemble voting,91.4)
    };
\end{axis}
\end{tikzpicture}

\end{document}
percusse
  • 157,807