Multiplot命令可以将几个图放置在同一个页面、窗口或屏幕上。
The command multiplot places several plots are placed on the same page, window, or screen.
Syntax:
set multiplot { layout ,
{rowsfirst|columnsfirst} {downwards|upwards}
{title }
{scale {,}} {offset {,}}
}unset multiplot
torch/gnuplot.lua支持了plot,splot,scatter3,imagesc,bar,hist
接口,raw
可以输入gnuplot原始命令。使得我们可以用lua语言将torch7数据绘制成gnuplot图片。
窍门:
除了将torch数据输入到窗口时用封装接口,对窗口设置都用raw
接口。强调虽然xlabel,title
等命令也有封装接口,别在multiplot时使用,会造成子图重叠错乱。
使用案例:
require "gnuplot"
require "torch"
x1 = torch.randn(20, 20)
x2 = torch.randn(10, 10)
x3 = torch.randn(5, 5)
gnuplot.setterm("png")
gnuplot.pngfigure("test.png")
gnuplot.raw("set output 'test.png'") --a necessary step before multiplot
gnuplot.raw("set multiplot layout 2,2 columnsfirst title 'MyFigure'")
--first plot
gnuplot.raw([[set title 'x1'
set xlabel 'X'
set ylabel 'Y'
]])
gnuplot.imagesc(x1, "color")
--second plot
gnuplot.raw([[set title 'x2'
set xlabel 'X'
set ylabel 'Y'
]])
gnuplot.imagesc(x2, "color")
--third plot
gnuplot.raw([[set title 'x3'
set xlabel 'X'
set ylabel 'Y'
]])
gnuplot.imagesc(x3, "color")
gnuplot.raw("unset multiplot")
###参考