棒グラフラテックス

棒グラフラテックス

このコードが最初の 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}

関連情報