gnuplot - Gnuplot multiplot 中的双列图
问题描述
我尝试创建多图(2x2)和单个图的组合。我不确定我做错了什么,但我不知道该怎么做。我的尝试:
plot sin(x) title "this should be a single plot"
set multiplot layout 2,2 title "Those are the multiplots"
set title "A!"
plot sin(x)
set title "B!"
plot cos(x) not
set title "C!"
tan(x) title "tan"
set title "D"
tan(0.5*x) not
无论我将情节放在之后还是之前,但我无法想象它。
谢谢。
解决方案
您应该在最后两个函数之前添加一个绘图命令,并且可能在最后添加一个unset multiplot
。这应该有效。还是您希望单图和多图都可见?
plot sin(x) title "this should be a single plot"
set multiplot layout 2,2 title "Those are the multiplots"
set title "A!"
plot sin(x)
set title "B!"
plot cos(x) not
set title "C!"
plot tan(x) title "tan"
set title "D"
plot tan(0.5*x) not
unset multiplot
编辑:(手动设置大小、原点和边距)
### Multiplot layout
reset session
set multiplot title "These are five plots"
set ytics 0.5
set margins 5,5,2,8 # l,r,b,t
set size 1,0.5
set origin 0,0.6
set title "top plot"
plot sin(x) title "this should be a single plot"
set size 0.5,0.5
set origin 0,0.3
set title "A!"
plot sin(x)
set origin 0.5,0.3
set title "B!"
plot cos(x)
set origin 0,0
set title "C!"
plot sin(2*x)
set origin 0.5,0
set title "D"
plot cos(2*x)
unset multiplot
### end of code
结果:
添加:
只是为了好玩,也许它对你或其他人有用。只需几行,您就可以轻松地在矩阵中设置布局,其中存储了一些数字$Layout
。我希望它是自我解释的。
代码:(编辑:简化)
### easy configurable multiplot layout
reset session
# row column height width
$Layout <<EOD
1 1 1 1
1 2 2 2
1 4 2 1
2 1 1 1
3 1 1 4
EOD
stats $Layout u ($1+$3):($2+$4) nooutput # get max number of rows and columns
MPRows = STATS_max_x - 1
MPCols = STATS_max_y - 1
r(i) = word($Layout[i],1)
c(i) = word($Layout[i],2)
h(i) = word($Layout[i],3)
w(i) = word($Layout[i],4)
MPGridX = 1.0/MPCols
MPGridY = 1.0/MPRows
MPSizeX(i) = MPGridX*w(i)
MPSizeY(i) = MPGridY*h(i)
MPOriginX(i) = MPGridX*(c(i)-1)
MPOriginY(i) = 1-MPGridY*(r(i)+h(i)-1)
SetLayout = 'i=i+1; \
set origin MPOriginX(i), MPOriginY(i); \
set size MPSizeX(i) , MPSizeY(i)'
set multiplot
set linetype 1 lc rgb "red"
i=0
@SetLayout
plot sin(x)
@SetLayout
plot cos(x)
@SetLayout
plot x**3
@SetLayout
plot x**2
@SetLayout
plot sin(x)/x
unset multiplot
### end of code
结果:
推荐阅读
- javascript - 来自表示组件的打字稿中的异步调度调用
- common-lisp - cons的规格
- kivy - 动画实例未清理
- kubernetes - 什么 Kubernetes 服务/pod 应该在端口 6784 上监听?
- ios - iOS - 未使用日志“[Crashlytics:Crash] Reporting is disabled”记录崩溃
- intellij-idea - Intellij 快速文档显示在单独的面板中,而不是弹出窗口
- javascript - JavaScript 未来价值计算器
- javascript - 使用 JavaScript 的 Yelp API 授权
- r - 如何在发送拉取请求之前测试分叉的 R 包的更改?
- go - 使用“dep”管理项目依赖时,没有安装 iris 的“hero”组件