x 轴上的值范围未使用我的数据中的值。我如何将范围数据调整为 2000 步,即 0、2000、4000、... 等?
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar,
xmin=0,
width=12cm,
height=7cm,
%enlarge y limits=0.5,
xlabel={Datensätze},
%ylabel={Unternehmen},
symbolic y coords={Exasol,Steinhoff,Vonovia,Fraport,Gazprom,Apple,Berkshire Hathaway,Microsoft,Deutsche Bank},
ytick=data,
nodes near coords,
nodes near coords align={horizontal},
legend style={at={(0.5,-0.2)},anchor=north, legend columns=-1},
x tick label style={rotate=45,anchor=east},
]
\addplot coordinates{
(14587,Deutsche Bank)
(22842,Microsoft)
(10464,Berkshire Hathaway)
(6035,Apple)
(8127,Gazprom)
(2822,Fraport)
(129,Vonovia)
(393,Steinhoff)
(2439,Exasol)
};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您只需指定xtick
s 即可。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar,
xmin=0,
width=12cm,
height=7cm,
%enlarge y limits=0.5,
xlabel={Datens\"atze},
xmax=26000,
%ylabel={Unternehmen},
symbolic y coords={Exasol,Steinhoff,Vonovia,Fraport,Gazprom,Apple,Berkshire Hathaway,Microsoft,Deutsche Bank},
ytick=data,
nodes near coords,
nodes near coords align={horizontal},
legend style={at={(0.5,-0.2)},anchor=north, legend columns=-1},
xtick={0,2000,...,26000},scaled x ticks=false,
x tick label style={rotate=45,anchor=east},
]
\addplot coordinates{
(14587,Deutsche Bank)
(22842,Microsoft)
(10464,Berkshire Hathaway)
(6035,Apple)
(8127,Gazprom)
(2822,Fraport)
(129,Vonovia)
(393,Steinhoff)
(2439,Exasol)
};
\end{axis}
\end{tikzpicture}
\end{document}
如果你删除scaled x ticks=false,
你得到