我的直方图有问题。我的 y 轴不是我想要的格式。我想要 y-min = 0 和 y-max = 12000,但我的图形以幂元素表示。
代码如下:
\documentclass[A4,11pt,twoside]{book}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{makeidx}
\usepackage{graphicx,subfig}
\usepackage{array, booktabs}
\begin{document}
\begin{center}
\begin{tikzpicture}[font=\small]
\begin{axis}[ybar,ymin=0.0,ymax=12000.0,
height=8cm,
ymajorgrids=true,
ylabel={Risposte},
symbolic x coords={
$18-30$, $31-40$, $41-50$, $50-100$},
xtick=data, nodes near coords,
xlabel={Anni},
nodes near coords align={vertical},
xtick pos=left]
\addplot [fill=blue,draw=black, ball color=blue] coordinates{
($18-30$,1411)($31-40$,2486) ($41-50$,4258) ($50-100$,10841)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
答案1
我认为这个问题已经得到解答这里但因为我仍然无法评论,所以我会回答。正如PGFplots 手册使用 axis 选项scaled y ticks = false
解决了这个问题。下面是 MWE:
\documentclass[a4paper,11pt,twoside]{book}
\usepackage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}[font=\small]
\begin{axis}[ybar, ymin=0.0, ymax=12000.0, ymajorgrids=true, ylabel={Risposte},
scaled y ticks = false,
xtick=data, xlabel={Anni}, xtick pos=left,
symbolic x coords={ $18-30$, $31-40$, $41-50$, $50-100$},
nodes near coords, nodes near coords align={vertical}, height=8cm]
\addplot [fill=blue,draw=black, ball color=blue] coordinates{ ($18-30$,1411)($31-40$,2486) ($41-50$,4258) ($50-100$,10841)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}