14

Is there a way to interrupt the bar charts in pgfplots? More specifically, I have a plots with bar charts and one chart has extremely high values, so that you can hardly see the others in a scale. This is the code:

\documentclass{article}

\usepackage{pgfplots}

\usepackage{booktabs}

\usepackage[autolanguage, np]{numprint}

\begin{document}

\begin{figure*}
\centering
\begin{tikzpicture}
\begin{axis} [
footnotesize,
ybar=0,

/pgf/bar width = 5\heavyrulewidth, width=\linewidth, height=0.36\linewidth, symbolic x coords={avrora,batik,eclipse,fop,h2,jython,luindex,lusearch,pmd,sunflow,xalan,Geo. mean}, xtick=data, % Ticks only at symbolic x coords x tick label style={rotate=45,anchor=north east}, ylabel={Overhead}, ymajorgrids=true, ymin=1, yticklabel={\nprounddigits{0}\np[x]{\tick}}, legend style={at={(0,1)}, anchor=north west, legend columns=-1}, legend plot pos=right, error bars/y dir=both, error bars/y explicit, xticklabels={ \textsf{avrora}, \textsf{batik}, \textsf{eclipse}, \textsf{fop}, \textsf{h2}, \textsf{jython}, \textsf{luindex}, \textsf{lusearch}, \textsf{pmd}, \textsf{sunflow}, \textsf{xalan}, Geo. mean}, cycle list={fill=white,fill=magenta,fill=cyan}, ] \addplot coordinates { (avrora,86.19)+-(0,11.9602) (batik,27.56)+-(0,0.5393) (eclipse,148.06)+-(0,70.1225) (fop,61.0333333333333)+-(0,1.8024) (h2,145.046666666667)+-(0,9.6426) (jython,257.89)+-(0,25.3882) (luindex,72.5366666666667)+-(0,1.5383) (lusearch,1030.43666666667)+-(0,67.5483) (pmd,39.0033333333333)+-(0,1.4052) (sunflow,336.05)+-(0,27.3135)
(xalan,483.416666666667)+-(0,45.2582) (Geo. mean,139.201682374624) };

\addplot coordinates { (avrora,455.47)+-(0,46.3514) (batik,49.52)+-(0,0.9035) (eclipse,88.48)+-(0,7.2219) (fop,42.21)+-(0,7.9335) (h2,295.56)+-(0,24.2355) (jython,268.63)+-(0,24.3776) (luindex,245.54)+-(0,5.7191) (lusearch,3281.2)+-(0,160.5282) (pmd,36.53)+-(0,1.1229) (sunflow,475.62)+-(0,12.5994) (xalan,1315.85)+-(0,124.721219258526) (Geo. mean,235.434550719032) }; \end{axis} \end{tikzpicture} \end{figure*}

that ends up in this plot: enter image description here

The bar for lusearch is extremely high and therefore other bars become really small. I would like to interrupt the values at 1500X and continue from 2500X to 3000X just to show the top of lusearch and so that other charts would be much bigger.

I hope I was clear with the explanation.

UPD: I've updated the example, so that you can run it. Sorry for not doing at first.

Stefan Pinnow
  • 29,535
bekon
  • 449

1 Answers1

8

I have only a solution with PSTricks. Run the example with xelatex. Can be extended to your special example. Needs up-to-date TeXLive or pst-plot.tex from http://texnik.dante.de/tex/generic/pst-plot/

\documentclass{article}
\usepackage{pst-plot}    
\begin{document}   
\section*{An interrupted plot}

\psset{xunit=.44cm,yunit=.3cm}
\begin{pspicture}(-2,-3)(29,32)
\psaxes[axesstyle=axes,ticksize=-4pt 0,Dy=2,Dx=2](29,15)
\rput(0,15.4){\textbf{\huge$\approx$}}
\rput(0,16){\psaxes[xAxis=false,ticksize=-4pt 0,
  Dy=2,Oy=46,Dx=2](29,15)}
\psset{interrupt={15,1,30}}
\listplot[linecolor=red,plotstyle=bar,barwidth=0.3cm,
  fillcolor=red!30,fillstyle=solid]{
0 0  1 0 2  0  3  0  4  0  5  0  6  0  7  0  8  0  9 1  10 2  
11 1  12  50  13 55  14 14  15 7  16  9  17 7  18  4 
19  2  20  3  21  0  22  0  23  0  24  1 25  2  % 1st example
}
\listplot[linecolor=blue,plotstyle=bar,barwidth=0.3cm,
  fillcolor=blue!30,fillstyle=solid,opacity=0.5]{
0 0  1 0 2  0  3  0  4  0  5  0  6  0  7  0  8  0  9 3  10 10  
11 11  12  8  13 61  14 10  15 13  16  3  17 1  18  0 
19  0  20  2  21  0  22  0  23  0  24  0 25  0  % 2nd exa
}
\listplot[linecolor=green,plotstyle=bar,barwidth=0.3cm,
  fillcolor=green!30,fillstyle=solid,opacity=0.5]{
0 0 1 0 2  0  3  0  4  1  5  0  6  0  7  0  8  0  9 3  10 4  
11 11  12  59  13 11  14 12  15 7  16  3  17 1  18  0 
19  0  20  2  21  0  22  1  23  0  24  0 25  0  % 3rd exa
}
\end{pspicture}   
\end{document}

\psset{interrupt={15,1,30}}: start,sep,diff

enter image description here

  • Thanks Herbert! Given the strict time constraints I decided to go for a table instead of bar charts. I tried to extend your example, but after an hour of playing simply gave up. – bekon Nov 18 '12 at 15:05