如何在 pgfplots 中绘制中断条形图

如何在 pgfplots 中绘制中断条形图

有没有办法打断 pgfplots 中的条形图?更具体地说,我有一个带有条形图的图,其中一个图表的值非常高,因此您几乎看不到比例中的其他图表。这是代码:

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

最终的剧情是这样的: 在此处输入图片描述

lusearch 的条形图非常高,因此其他条形图变得非常小。我想在 1500X 处中断值,并从 2500X 继续到 3000X,只是为了显示 lusearch 的顶部,这样其他图表就会大得多。

我希望我的解释清楚了。

更新:我已经更新了示例,以便您可以运行它。抱歉一开始没这么做。

答案1

我只有一个 PSTricks 解决方案。使用 运行示例xelatex。可以扩展到您的特殊示例。需要最新的 TeXLive 或pst-plot.tex来自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}}:开始,结束,差异

在此处输入图片描述

相关内容