2

I try to plot coordinates near the bars, it works but I get the error

! Dimension too large.
<recently read> \pgfmath@x 

l.56 \end{axis}

I can't work with sizes bigger than about 19 feet.
Continue and I'll use the largest value I can.

Here is my script

\pgfplotstableread[row sep=\\,col sep=&]{
    interval & a & b & c \\
1 & 423.4191 & 406.7196 & 406.6987 \\
2 & 96.6418 & 95.6828 & 95.6796 \\
3 & 96.7403 & 95.6903 & 95.6870 \\
4 & 96.6698 & 95.7103 & 95.7072 \\
5 & 96.7684 & 95.7179 & 95.7146 \\
6 & 6.8072 & 1.8403 & 1.8406 \\
7 & 6.8072 & 1.8404 & 1.8408 \\
}\mydata
\pgfplotsset{/pgf/number format/use comma}
\pgfplotsset{compat=1.11,
    /pgfplots/ybar legend/.style={
        /pgfplots/legend image code/.code={%
            \draw[##1,/tikz/.cd,yshift=-0.25em]
            (0cm,0cm) rectangle (3pt,0.8em);},
    },
}
\begin{tikzpicture}[font=\scriptsize]
%\draw[help lines,xstep=0.5,ystep=0.5,color=lightgray] (0,0) grid (6,5);
%\foreach \x in {0,1,...,6.5} { \node [anchor=north] at (\x,0) {\x}; }
%\foreach \y in {0,1,...,5} { \node [anchor=east] at (0,\y) {\y}; }
\begin{axis}[
ybar,
bar width=.125cm,
width=.5\textwidth,
height=.35\textwidth,
xtick=data,
xticklabels={(a),(b),(c),(d),(e),(f),(g)},
%xticklabel style={rotate=45,font=\scriptsize,yshift=1ex,anchor=north east},
xmajorgrids=false,
ymin=0,ymax=500,
ylabel={probability [ppm]},
%y label style={at={(0.05,0.5)}},
ymajorgrids=true,
yminorgrids=true,
minor y tick num=1,
ytick={0,100,200,300,400,500},
major grid style={lightgray},
minor grid style={lightgray},
every node near coord/.append style={rotate=60, anchor=west,font=\tiny},
%nodes near coords,
legend style={at={(0.5,1)},anchor=north,legend columns=-1,append after command={
        \pgfextra{
            \draw[draw=none,
            drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}]
            (\tikzlastnode.south west)rectangle(\tikzlastnode.north east);
        }   
    },  
},
blur shadow]
\addplot[nodes near coords,fill=lightgray] table[x=interval,y=a]{\mydata};
\addplot[fill=gray] table[x=interval,y=b]{\mydata};
\addplot[fill=darkgray] table[x=interval,y=c]{\mydata};
\legend{spc, mpc, mpc-c}
\end{axis}
\end{tikzpicture}
2
  • 2
    Things work best if you include the entire file (trimmed down to size). Everything from \documentclass to \end{document}. Then we can all start from the same page.
    – Teepeemm
    Feb 27, 2017 at 16:23
  • The document is compiling without any errors for me. Could you reduce it so that it will become a real MWE ? For example, remove all the shadow stuff and give a ready to compile document, including a preamble ?
    – mvienney
    Feb 27, 2017 at 17:37

1 Answer 1

2

If I reduce your code to a minimal (non)-working example, by removing piece by piece, I'm left with this:

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{shadows.blur}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
blur shadow
]
\addplot coordinates{(0,0)(1,1)};
\end{axis}
\end{tikzpicture}
\end{document}

That code will throw the error you mention, but removing the blur shadow option from the axis environment makes it work. And indeed, if I take your code, add the missing parts, and remove blur shadow, I get this:

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{shadows.blur}
\begin{document}
\pgfplotstableread[row sep=\\,col sep=&]{
    interval & a & b & c \\
1 & 423.4191 & 406.7196 & 406.6987 \\
2 & 96.6418 & 95.6828 & 95.6796 \\
3 & 96.7403 & 95.6903 & 95.6870 \\
4 & 96.6698 & 95.7103 & 95.7072 \\
5 & 96.7684 & 95.7179 & 95.7146 \\
6 & 6.8072 & 1.8403 & 1.8406 \\
7 & 6.8072 & 1.8404 & 1.8408 \\
}\mydata
\pgfplotsset{/pgf/number format/use comma}
\pgfplotsset{compat=1.11,
    /pgfplots/ybar legend/.style={
        /pgfplots/legend image code/.code={%
            \draw[##1,/tikz/.cd,yshift=-0.25em]
            (0cm,0cm) rectangle (3pt,0.8em);},
    },
}
\begin{tikzpicture}[font=\scriptsize]
%\draw[help lines,xstep=0.5,ystep=0.5,color=lightgray] (0,0) grid (6,5);
%\foreach \x in {0,1,...,6.5} { \node [anchor=north] at (\x,0) {\x}; }
%\foreach \y in {0,1,...,5} { \node [anchor=east] at (0,\y) {\y}; }
\begin{axis}[
ybar,
bar width=.125cm,
width=.5\textwidth,
height=.35\textwidth,
xtick=data,
xticklabels={(a),(b),(c),(d),(e),(f),(g)},
%xticklabel style={rotate=45,font=\scriptsize,yshift=1ex,anchor=north east},
xmajorgrids=false,
ymin=0,ymax=500,
ylabel={probability [ppm]},
%y label style={at={(0.05,0.5)}},
ymajorgrids=true,
yminorgrids=true,
minor y tick num=1,
ytick={0,100,200,300,400,500},
major grid style={lightgray},
minor grid style={lightgray},
every node near coord/.append style={rotate=60, anchor=west,font=\tiny},
%nodes near coords,
legend style={at={(0.5,1)},anchor=north,legend columns=-1,append after command={
        \pgfextra{
            \draw[draw=none,
            drop shadow={fill=black, opacity=0.5, shadow xshift=2pt, shadow yshift=-2pt}]
            (\tikzlastnode.south west)rectangle(\tikzlastnode.north east);
        }   
    },  
},
%blur shadow  %%% commented out
]
\addplot[nodes near coords,fill=lightgray] table[x=interval,y=a]{\mydata};
\addplot[fill=gray] table[x=interval,y=b]{\mydata};
\addplot[fill=darkgray] table[x=interval,y=c]{\mydata};
\legend{spc, mpc, mpc-c}
\end{axis}
\end{tikzpicture}
\end{document}
1
  • You are right, the blur shadow comand is the problem. Thank you!
    – Michael
    Feb 28, 2017 at 10:54

You must log in to answer this question.

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