如何将两个box-whisker图组合成一个使用gnuplot [英] How to combine two box-whisker plots into one using gnuplot

查看:189
本文介绍了如何将两个box-whisker图组合成一个使用gnuplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个盒须图,一个显示时间,另一个显示内存使用情况。请看下面:

显示时间使用情况的盒须图:
http://goo.gl/jhYBXr



显示内存使用情况的Box-Whisker图:
http://goo.gl/0Wvamh



gnuplot中是否有将这两个成1图?理想情况下,我想每个'X'进入两个盒须图。将会有两个Y轴 - 显示时间y1和显示不同范围内存的y2。



预先感谢您。 任何示例数据,我都使用了gnuplot的 candlestick.dem demo中的数据,并假设您在第一列中包含JDK数字:

  2.1 1 1.5 2 2.4 4 6. 
2.2 2 1.5 3 3.5 4 5.5
3.0 3 4.5 5 5.5 6 6.5
3.1 4 3.7 4.5 5.0 5.5 6.1
4.0 5 3.1 3.5 4.2 5 6.1
5.0 6 1 4 5.0 6 9
6.0 7 4 4 4.8 6 6.1
7.0 8 4 5 5.1 6 6.1

绘图完成如下:


  1. 绘制一个空图(使用 linetype -3 ,它不会绘制任何东西)并使用 xticlabels 来生成自定义xtics。


  2. 绘制时间使用的盒须相对于xtic


  3. 绘制盒式胡须的内存使用情况向右移动了一下,相对于xtic

  4. >

为简单起见,这里我对时间和内存使用相同的数据,但您当然可以使用不同的数据文件和不同的 y2range yrange

  set boxwidth 0.2 absolute 
set offset 0.5,0.5,0,0

set yrange [0:10]
set y2range [0:10]
set ytics nomirror
set y2tics
set ylabel'time usage'
set y2label'内存使用'
set xlabel'JDKs'

set key left

使用2:4:xticlabels(1)linetype -3 notitle,\
'绘制'data.txt'使用($ 2-0.15):4:3:7:6烛型线型1 title''Quartles,time'whiskerbars,\
''使用($ 2-0.15):5:5:5:5用烛台linetype -1 linewidth 2 notitle,\
'data.txt'使用($ 2 + 0.15):4:3:7:6使用烛台线型2轴x1y2标题'Quartiles,memory'whiskerbars,\
''使用($ 2 + 0.15):5:5:5:5用烛台linetype -1 li newidth 2 axes x1y2 notitle

这给出:


I have two box-whisker plots, one showing time, another memory usage. Please see below:

Box-Whisker plot showing time usage: http://goo.gl/jhYBXr

Box-Whisker plot showing memory usage: http://goo.gl/0Wvamh

Is there anyway in gnuplot to combine these two into 1 graph? Ideally, I want two box-whisker plots per 'X' entry side-by-side. There will be two Y-axis - y1 showing time and y2 showing memory with different range.

Thanks in advance.

解决方案

As you haven't provided any example data, I used the data from gnuplot's candlestick.dem demo and assumed, you have the JDK numbers in the first column:

2.1 1 1.5 2   2.4 4   6.
2.2 2 1.5 3   3.5 4   5.5
3.0 3 4.5 5   5.5 6   6.5
3.1 4 3.7 4.5 5.0 5.5 6.1
4.0 5 3.1 3.5 4.2 5   6.1
5.0 6 1   4   5.0 6   9
6.0 7 4   4   4.8 6   6.1
7.0 8 4   5   5.1 6   6.1

The plotting is done like follows:

  1. Plot an empty plot (with linetype -3, which doesn't draw anything) and use xticlabels to generate the custom xtics.

  2. Plot the box-whiskers for the time usage shifted a bit to the left relative to the xtic

  3. Plot the box-whiskers for the memory usage shifted a bit to the right relative to the xtic

For simplicity, here I use the same data for both time and memory, but you can of course use different data files and different y2range and yrange:

set boxwidth 0.2 absolute
set offset 0.5,0.5,0,0

set yrange[0:10]
set y2range[0:10]
set ytics nomirror
set y2tics
set ylabel 'time usage'
set y2label 'memory usage'
set xlabel 'JDKs'

set key left

plot 'data.txt' using 2:4:xticlabels(1) linetype -3 notitle,\
     '' using ($2-0.15):4:3:7:6 with candlesticks linetype 1 title 'Quartiles, time' whiskerbars,\
     '' using ($2-0.15):5:5:5:5 with candlesticks linetype -1 linewidth 2 notitle,\
     'data.txt' using ($2+0.15):4:3:7:6 with candlesticks linetype 2 axes x1y2 title 'Quartiles, memory' whiskerbars,\
     '' using ($2+0.15):5:5:5:5 with candlesticks linetype -1 linewidth 2 axes x1y2 notitle

This gives:

这篇关于如何将两个box-whisker图组合成一个使用gnuplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆