我正在尝试制作类似于下图的条形图,但遇到了麻烦,因为我找不到一种方法来制作没有错误的 x 轴标签,因为它们由等表示$\ket{000}$
。
以下是我正在尝试做的事情
\begin{tikzpicture}
\begin{axis}[
x tick label style={
/pgf/number format/1000 sep=},
ylabel=Year,
enlargelimits=0.05,
legend style={at={(0.5,-0.1)},
anchor=north,legend columns=-1},
ybar interval=0.7,
]
\addplot
coordinates {($\ket{000}$,4) ($\ket{001}$,4)
($\ket{010}$,7) ($\ket{011}$,-5) ($\ket{100}$,3)};
\end{axis}
\end{tikzpicture}
答案1
像这样吗?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{braket}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x tick label style={/pgf/number format/1000 sep=},
ylabel=Year,
enlargelimits=0.05,
legend style={at={(0.5,-0.1)},anchor=north,legend columns=-1},
ybar interval=0.7,
symbolic x coords = {$\ket{000}$, $\ket{001}$, $\ket{010}$, $\ket{011}$, $\ket{100}$, 6}
]
\addplot
coordinates {($\ket{000}$,4) ($\ket{001}$,4) ($\ket{010}$,7) ($\ket{011}$,-5) ($\ket{100}$,3) (6,3)};
\end{axis}
\end{tikzpicture}
\end{document}