如何分别用对角线和网格图案替换图片中所示的蓝色背景?
我目前无法找到适合我这种图表的简洁解决方案。
代码
\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}
输出
答案1
\addplot
您可以在选项中使用 TikZ 绘图选项。
\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}