我正在创建一些工业疲劳图,但在 MWE 上,勾号和勾号标签“C”没有出现,我不知道为什么以及如何纠正这个问题。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.5.1}
\usepackage{caption}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title= {Fatigue test results per configuration.},
y tick label style={
/pgf/number format/.cd,
fixed,
1000 sep={\thinspace},
precision=0,
/tikz/.cd
},
only marks,enlargelimits=0.15,
xlabel={Configuration style},ylabel={Cycles before failure},
symbolic x coords={A,C}, xtick=data,]
\addplot coordinates {(A,1362)(A,2840) (A,687)(A,2771)};
\addplot coordinates {(C,2130)(C,3544) (C,1844)(C,3447)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
xtick=data
仅使用第一个\addplot
命令来确定刻度位置。您应该改用xtick={A,C}
。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.5.1}
\usepackage{caption}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title= {Fatigue test results per configuration.},
y tick label style={
/pgf/number format/.cd,
fixed,
1000 sep={\thinspace},
precision=0,
/tikz/.cd
},
only marks,enlargelimits=0.15,
xlabel={Configuration style},ylabel={Cycles before failure},
symbolic x coords={A,C}, xtick={A,C}]
\addplot coordinates {(A,1362)(A,2840) (A,687)
(A,2771)};
\addplot coordinates {(C,2130)(C,3544) (C,1844)(C,3447)};
\end{axis}
\end{tikzpicture}
\end{document}