图中有两个“带盒子"的地块. gnuplot彼此相邻 [英] Two plots "with boxes" next to each other with gnuplot

查看:74
本文介绍了图中有两个“带盒子"的地块. gnuplot彼此相邻的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在一张图中绘制两个数据系列,作为gnuplot中的框.该脚本当前如下所示:

I am trying to have two data series plotted in one graph as boxes in gnuplot. The script looks like this currently:

set terminal postscript eps enhanced color
set title "Distribution of the extrepreneur PnL. Loan $6."
set output 'pnl_loan6.eps'


#set xrange [0:]
set xlabel "Discounted profit"

set style fill solid 0.8 border -1
plot 'pnl_loan6.txt' using 1:2 title 'PnL high risk (xi=1)' with boxes,\
     'pnl_loan6.txt' using 1:3 title 'PnL high risk (xi=1.5)' with boxes

但这两个系列重叠.除了重叠之外,我希望一个系列在现有框的左半部分绘制其框,而另一组在右半部分绘制,以使它们有效地交替.我该怎么办?

however the two series overlap. Instead of the overlap I would like to have one series draw its box in the left half of the existing box, and the other one in the right half, so that they effectively alternate. How can I do it?

  1. 我尝试了直方图,但这看起来不太好. Xtics不是我所追求的,两列之间有空格.
  2. 样本数据(每100列中的前20列):

数据:

-10.000000 20251.000000 31825.000000
-4.892638 26743.000000 21310.000000
0.214725 20362.000000 14590.000000
5.322087 13023.000000 9645.000000
10.429449 7730.000000 6347.000000
15.536812 4636.000000 4331.000000
20.644174 2714.000000 2964.000000
25.751536 1647.000000 2121.000000
30.858899 1044.000000 1586.000000
35.966261 648.000000 1106.000000
41.073624 396.000000 873.000000
46.180986 257.000000 685.000000
51.288348 166.000000 471.000000
56.395711 101.000000 369.000000
61.503073 83.000000 321.000000
66.610435 52.000000 260.000000
71.717798 40.000000 184.000000
76.825160 30.000000 172.000000
81.932522 21.000000 143.000000
87.039885 11.000000 116.000000

推荐答案

我不太确定您要做什么,但是也许这种小小的黑客方法可以解决问题:

I am not really sure what you are after but maybe this little hackerish approach will do the trick:

set style fill solid 0.8 border -1
set boxwidth 0.5 relative
plot 'pnl_loan6.txt' using ($1+1.27684075):2 title 'PnL high risk (xi=1)' with boxes,\
     'pnl_loan6.txt' using ($1-1.27684075):3 title 'PnL high risk (xi=1.5)' with boxes

与脚本的区别是

  1. 设置boxwidth相对为0.5
  2. 将图偏移x轴上一半的距离(这仅适用于您,因为您的x轴缩放比例是等距的.

无论如何,这是结果图:

Anyhow this is the resulting plot:

PS: 您可能需要考虑使用set logscale y在y轴上进行对数缩放,从而得出此图:

PS: You might want to think about a logarithmic scaling on the y-axis with set logscale y which would result in this plot:

这篇关于图中有两个“带盒子"的地块. gnuplot彼此相邻的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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