pgfplots 黑白线图

pgfplots 黑白线图

您好,参考了 pgfplots 用户手册,但没有找到关于如何创建黑白线图的说明。我的图表如下

\begin{figure}[H]
\begin{tikzpicture}
\begin{axis}[
scaled y ticks=real:150,
ytick scale label code/.code={},
ymax = 150,
symbolic x coords={8 by 8, 16 by 16,32 by 32,64 by 64},
xtick=data,
height=9cm,
width=8cm,
grid=major,
xlabel={Dimensions},
ylabel={Force},
legend style={
cells={anchor=east},
legend pos=south east,
}
]

\addplot coordinates {
(8 by 8,38) (16 by 16, 50)  (32 by 32, 69)  (64 by 64, 99) 
};


\addplot coordinates {
(8 by 8,43)  (16 by 16, 66) (32 by 32, 92)  (64 by 64, 118)
};

\addplot coordinates {
(8 by 8,25)  (16 by 16, 81) (32 by 32, 91)  (64 by 64, 150)
};

\addplot coordinates {
(8 by 8,100)  (16 by 16, 145)   (32 by 32, 146) (64 by 64, 150)
};

\addplot coordinates {
(8 by 8, 12)  (16 by 16, 135)   (32 by 32,141)  (64 by 64, 149)
};

\addplot coordinates {
(8 by 8, 111)  (16 by 16, 138)  (32 by 32, 140) (64 by 64, 145)
};

\addplot coordinates {
(8 by 8, 76)  (16 by 16, 121)   (32 by 32, 140) (64 by 64, 147)
};


\legend{$AAAA$,$BBBB$,$CCCC$,$DDDD$,$EEEE$,$FFFF$,$GGGG$}
\end{axis}
\end{tikzpicture}
     \caption{Force as area increases}
     \label{fig:force}
\end{figure}




\end{document}

在此处输入图片描述

我也发布了结果图。我不知道如何给每条线赋予一个唯一的符号。有人能帮帮我吗?

答案1

您可以使用黑白颜色循环列表或添加

\selectcolormodel{gray}

在环境内部tikzpicture

\begin{tikzpicture}
\selectcolormodel{gray}
\begin{axis}[
scaled y ticks=real:150,
ytick scale label code/.code={},
ymax = 150,
symbolic x coords={8 by 8, 16 by 16,32 by 32,64 by 64},
xtick=data,
height=9cm,
width=8cm,
grid=major,
xlabel={Dimensions},
ylabel={Force},
legend style={
cells={anchor=east},
legend pos=south east,
}
]
\addplot coordinates {(8 by 8,38) (16 by 16, 50)  (32 by 32, 69)  (64 by 64, 99)};
\addplot coordinates {(8 by 8,43)  (16 by 16, 66) (32 by 32, 92)  (64 by 64, 118)};
\addplot coordinates {(8 by 8,25)  (16 by 16, 81) (32 by 32, 91)  (64 by 64, 150)};
\addplot coordinates {(8 by 8,100)  (16 by 16, 145)   (32 by 32, 146) (64 by 64, 150)};
\addplot coordinates {(8 by 8, 12)  (16 by 16, 135)   (32 by 32,141)  (64 by 64, 149)};
\addplot coordinates {(8 by 8, 111)  (16 by 16, 138)  (32 by 32, 140) (64 by 64, 145)};
\addplot coordinates {(8 by 8, 76)  (16 by 16, 121)   (32 by 32, 140) (64 by 64, 147)};
\legend{$AAAA$,$BBBB$,$CCCC$,$DDDD$,$EEEE$,$FFFF$,$GGGG$}
\end{axis}
\end{tikzpicture}

在此处输入图片描述

相关内容