8

With the following MWE (I want to plot a bar chart with symbolic coordinates using pgfplots) I get an error that I have no idea how to fix:

Package pgfplots Warning: You have an axis with empty range (in direction x)

MWE:

\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}
0
7

The mesagee is a warning, not an error.

To prevent it, provide appropriate values for xmin, xmax; also, there was a missing comma after 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}

enter image description here

2
  • You are right, it is warning, sorry for that. How do I do to show every value symbolic x coordinate as a tick in the x axis? In your answer I only see 6 values. Thanks! – petobens Mar 20 '14 at 1:03
  • 2
    @petobens You can use xtick, as in xtick={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}, – Gonzalo Medina Mar 20 '14 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.