我一直在想办法将图表从科学计数法改为只显示 5 位数字。我试过缩放和刻度刻度,但没有成功。
我如何更改 y 轴和数据值以显示非科学计数法的小数?
\begin{tikzpicture}
\centering
\begin{axis}[
width=300pt,
height=250pt,
axis lines*=left, % Don't display the top and right lines
ybar, % Display it as a bargraph
enlarge y limits={upper,value=0.2},
legend style={at={(0.5,-0.20)}, % -.20 y-axis
anchor=north,legend columns=-1},
ylabel={Densities},
nodes near coords,
every node near coord/.append style={ anchor=mid west, rotate=90},
symbolic x coords={Class1,Class3,Class5,Class7,Class9,Class11,Class13,Class15,Class17,Class19,Class21,Class23},
xtick=data,
xticklabel style={ inner sep=0pt, anchor=north east, rotate=70 },
nodes near coords align={vertical},
]
\addplot coordinates { (Class1,0.0968) (Class3,0.0887) (Class5,0.1452) (Class7,0.0726)
(Class9,0.0403) (Class11,0.0081) (Class13,0.0161) (Class15,0.0000)
(Class17,0.0161) (Class19,0.0081) (Class21,0.0000) (Class23,0.0081) };
\end{axis}
\end{tikzpicture}
答案1
您可以使用yticklabel style={/pgf/number format/fixed}
:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\centering
\begin{axis}[
width=300pt,
height=250pt,
axis lines*=left, % Don't display the top and right lines
ybar, % Display it as a bargraph
enlarge y limits={upper,value=0.2},
legend style={at={(0.5,-0.20)}, % -.20 y-axis
anchor=north,legend columns=-1},
ylabel={Densities},
nodes near coords,
every node near coord/.append style={ anchor=mid west, rotate=90},
symbolic x coords={Class1,Class3,Class5,Class7,Class9,Class11,Class13,Class15,Class17,Class19,Class21,Class23},
xtick=data,
xticklabel style={ inner sep=0pt, anchor=north east, rotate=70 },
nodes near coords align={vertical},
yticklabel style={/pgf/number format/fixed},
]
\addplot coordinates { (Class1,0.0968) (Class3,0.0887) (Class5,0.1452) (Class7,0.0726)
(Class9,0.0403) (Class11,0.0081) (Class13,0.0161) (Class15,0.0000)
(Class17,0.0161) (Class19,0.0081) (Class21,0.0000) (Class23,0.0081) };
\end{axis}
\end{tikzpicture}
\end{document}