2

How to avoid the error "! Package pgfplots Warning: Axis range for axis x is approximately empty; enlarging it" when there is only a single symbolic x coord in bar chart. Please see the following MWE:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[symbolic x coords = {Q6},xtick = data,ybar,ymin = 0]

\addplot[mark=none,Red,fill=Red] coordinates {(Q6,3)};
\addplot[mark=none,Orange,fill=Orange] coordinates {(Q6,4)};
\addplot[mark=none,Green,fill=Green] coordinates {(Q6,3)};
\addplot[mark=none,Blue,fill=Blue] coordinates {(Q6,3)};
\end{axis}

\end{tikzpicture}

\end{document}

I would be really grateful for any suggestions here.

Thank you.

1 Answer 1

4

It is not an error but a warning. Since you have only one x coordinate , pgfplots is trying to get the min and max values of the axis. But since there is one coordinate it finds out that the axis length is zero. So it says OK I'll enlarge it.

You can get both axes complain if you use

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[]
\addplot+[] coordinates {(1,0)};
\end{axis}
\end{tikzpicture}
\end{document}

Since now y axis max-min difference is also zero.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .