我原本用彩色绘制的图表需要打印在只允许黑白图形的期刊上。我有两个问题:
- 使不同的图表清晰区分的最佳方法是什么?
- 我怎样才能使用 PGF 图来实现这一点?
我搜索了 PGF 图手册,但似乎没有专用选项“colors=bwonly”或类似选项(也许是未来版本的一个方便的补充?)。
作为参考,这是我的原始图表:
\documentclass{minimal}
\usepackage{pgf,tikz}
\pgfplotsset{compat=1.5.1}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
%small,
ybar,%=8pt, % configures ‘bar shift’
enlargelimits=0.15,
ylabel={index},
symbolic x coords={1982, 1990, 1999, 2006},
%xtick=data,
%tick label style={font=\footnotesize},
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
nodes near coords,
%every node near coord/.style={font=\footnotesize},
nodes near coords align={vertical},
]
\addplot coordinates {(1982, 1.78) (1990, 1.71) (1999, 1.68) (2006, 1.62)};
\addplot coordinates {(1982, 1.70) (1990, 1.62) (1999, 1.59) (2006, 1.64)};
\addplot coordinates {(1982, 2.04) (1990, 1.96) (1999, 1.95) (2006, 1.91)};
\legend{A, B, C}
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您可以定义自己的颜色列表和线型列表,如第 4.6.7 节中所述pgfplots
手动的。
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
ylabel={index},
symbolic x coords={1982, 1990, 1999, 2006},
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
nodes near coords,
nodes near coords align={vertical},
cycle list = {black,black!70,black!40,black!10}
]
\addplot+[] coordinates {(1982, 1.78) (1990, 1.71) (1999, 1.68) (2006, 1.62)};
\addplot+[fill,text=black] coordinates {(1982, 1.70) (1990, 1.62) (1999, 1.59) (2006, 1.64)};
\addplot+[fill,,text=black] coordinates {(1982, 2.04) (1990, 1.96) (1999, 1.95) (2006, 1.91)};
\legend{A, B, C}
\end{axis}
\end{tikzpicture}
\end{document}