有人有办法在gnuplot中绘制bean图吗? [英] Anyone have a way to plot a bean plot in gnuplot?

查看:41
本文介绍了有人有办法在gnuplot中绘制bean图吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题很容易说明,但这是我想要做的事情的图片.我很难确定它是否可能.

Title is pretty self explanatory but here is a picture of what I'd like to do. I'm having a tough time figuring out if its even possible.

从以下位置借用的地块:评估硫化矿周围的地球化学背景水平–一种使用豆图的新统计程序.Gusstavason等.2012年.

Plot borrowed from: Evaluation of geochemical background levels around sulfide mines – A new statistical procedure with beanplots. Gusstavason et al. 2012.

推荐答案

以这种方向进行绘图可能非常麻烦,甚至可能的话.

Doing the plot in exactly this orientation could be very cumbersome, if possible at all.

我的建议是以所有方向绘制所有内容(例如,将沉积物"轴作为 x 轴,或者更确切地说作为 x2 轴),旋转所有标记一点,最后将完整的输出旋转 90 度(例如带有 pdftk 等的pdf文件).

My suggestion is to plot everything with the usual orientation (i.e. having the 'sediments' axis as x-axis, or rather as x2-axis), rotate all labels a bit and finally rotate the complete output by 90 degree (pdf file with e.g. pdftk etc).

使用此方法,您可以照常使用任何打印样式.在下面的脚本中,我仅向您展示如何绘制两个不同数据集的紫色和黄色填充曲线(使用伪数据).添加其他峰应该很简单(用 box vector 绘制样式绘制条形图).

With this you can use any plot style as usual. In the script below I just show you how to plot the violet and yellow filled curves (using pseudo data) for two different data sets. Adding the other peaks should be straight forward (plot the bars with e.g. boxes or vector plotting style).

为了使不同的图具有不同的 ytics ,我将某个 y 值与某个图 1 = Water 相关联,..., 4 = Gyttja ).

In order to have distinct ytics for the different plots, I associated a certain y-value with a certain plot, 1=Water, ..., 4=Gyttja).

全部放在一起将给出以下脚本:

Putting all toghether gives the following script:

reset
set terminal pdfcairo linewidth 2
outfile='bean'
set output outfile.'.pdf'
set encoding utf8

set x2range [0.5:9000]
set logscale x2
set x2tics (1, 5, 10, 50, '' 100, 500, '' 1000, 5000) out
set x2label 'mg/kg (sediments), µg/L (water)'
unset xtics

set yrange[0.5:4.5]
set ytics ('Water' 1, 'Minerogenic' 2, 'Peat' 3, 'Gyttja' 4) center rotate by -90 out

set label at graph 0.95, graph 0.05 right rotate by -90 'Nickel' font ',20' front
# cover possible data overlapping with the label
set object rectangle from graph 0.9, graph 0 to graph 1,graph 0.2 fillcolor rgb 'white' fillstyle solid noborder front

unset key

set macros
fs1="fillcolor rgb '#fc9e00' linewidth 2 fillstyle solid border lt -1"
fs2="fillcolor rgb '#9119f7' linewidth 2 fillstyle solid border lt -1"
# use pseudo data
set samples 500
plot '+' using 1:(4-0.3*exp(-(($1-10)/5.0)**4)) axes x2y1 with filledcurves y1=4 @fs1,\
     '' using 1:(4+0.2*exp(-(($1-70)/50.0)**4)) axes x2y1 with filledcurves y1=4 @fs2,\
     '' using 1:(1-0.4*exp(-(($1-5)/2.0)**2)) axes x2y1 with filledcurves y1=1 @fs1,\
     '' using 1:(1+0.1*exp(-(($1-30)/20.0)**2)) axes x2y1 with filledcurves y1=1 @fs2

set output
system(sprintf('pdftk %s.pdf cat 1W output %s-rot.pdf', outfile, outfile))
system(sprintf('pdftocairo -r 150 -png %s-rot.pdf', outfile))

这给出了4.6.3(并排和旋转的常规输出):

This gives (conventional and rotated output side-by-side) with 4.6.3:

伪数据需要一些东西.对于真实的数据文件,绘图线看起来有些不同.不同的图在 y 方向上有 1 的分隔,因此您必须相应地缩放数据(此处使用缩放因子 sc 手动完成)):

Some stuff is required for the pseudo data. For a real data file, the plotting line looks a bit differently. The different plots have a separation of 1 in y-direction, so you must scale your data accordingly (done here manually with a scaling factor sc):

sc = 5.1
plot 'datafile.txt' using 1:(4 + $2/sc) axes x2y1 with filledcurves y1=4 @fs1

您当然也可以通过使用 stats 命令提取一些最小值/最大值来自动进行缩放.

You can of course also do the scaling automatically, by extracting some minimum/maximum values using the stats command.

这篇关于有人有办法在gnuplot中绘制bean图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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