使用以下 MWE(我想使用符號座標繪製條形圖pgfplots
),我收到一個錯誤,我不知道如何修復:
Package pgfplots Warning: You have an axis with empty range (in direction x)
微量元素:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
% axis on top,
axis lines*=left,
ymajorgrids,
ybar,
ymin=0, ymax=2000,
xtick=data,
ytick = {0,200,400,600,800,1000,1200,1400,1600,1800},
bar width=0.1cm,
enlarge x limits=0.15,
enlarge y limits={upper, value=0.1},
x tick label style={font=\footnotesize,align=right,rotate=90},
symbolic x coords={jan12,feb12,mar12,apr12,may12,jun12,jul12,aug12,sep12,oct12,nov12,dec12
jan-13,feb-13,mar-13,apr-13,may-13,jun-13,jul-13,aug-13,sep-13,oct-13,nov-13,dec-13},
]
\end{axis}
\end{tikzpicture}
\end{document}
答案1
該訊息是一個警告,不是錯誤。
為了防止這種情況發生,請為 , 提供適當的值xmin
;xmax
另外,後面少了一個逗號dec12
:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
% axis on top,
axis lines*=left,
ymajorgrids,
ybar,
ymin=0, ymax=2000,
xmin=jan12, xmax=dec-13,
xtick=data,
ytick = {0,200,400,600,800,1000,1200,1400,1600,1800},
bar width=0.1cm,
enlarge x limits=0.15,
enlarge y limits={upper, value=0.1},
x tick label style={font=\footnotesize,align=right,rotate=90},
symbolic x coords={jan12,feb12,mar12,apr12,may12,jun12,jul12,aug12,sep12,oct12,nov12,dec12,
jan-13,feb-13,mar-13,apr-13,may-13,jun-13,jul-13,aug-13,sep-13,oct-13,nov-13,dec-13},
]
\end{axis}
\end{tikzpicture}
\end{document}