我不明白为什么此代码仅给我前 2 个条形图,而不是全部 3 个。其余格式都完美,只是不完整。
我需要改变什么?
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
xlabel=Utterance Type,
ylabel=Frequency,
symbolic x coords={Question, Statement, Uncertain},
xtick = data
enlargelimits=1,
ybar interval=0.4,
]
\addplot coordinates {(Question,4073) (Statement,8541) (Uncertain,2044)};
\end{axis}
\end{tikzpicture}\caption{Overall Responses by Utterance Type}\label{Overall}
\end{figure}
答案1
以下内容可能更接近您想要实现的目标:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
xlabel=Utterance Type,
ylabel=Frequency,
symbolic x coords={Question, Statement, Uncertain},
xtick = data,
ybar,
bar width=20pt,
]
\addplot coordinates {(Question,4073) (Statement,8541) (Uncertain,2044)};
\end{axis}
\end{tikzpicture}\caption{Overall Responses by Utterance Type}\label{Overall}
\end{figure}
\end{document}