Gnuplot:多图和插图
Gnuplot: multiplot and insets
我有两个情节,比如说
set multiplot # First plot with inset
plot exp(-x)
set size 0.6, 0.5
set origin 0.4, 0.5
plot cos(x)
unset multiplot
set multiplot # Second plot with inset
plot exp(-2x)
set size 0.6, 0.5
set origin 0.4, 0.5
plot sin(x)
unset multiplot
这将创建两个单独的图,但我真的想要两个图彼此相邻的单个输出。
作为伪代码,我希望像
set multiplot layout 1,2
set multiplot
plots+insets of first plot here
unset multiplot
set multiplot
plots+insets of second plot here
unset multiplot
unset multiplot
当然,我不认为你可以(轻松地)像那样嵌套多图,所以也许需要一种不同的方法?
重新表述这个问题:如何使用多图创建彼此相邻的不同图,以便其中一些图还包含插图(这本身需要使用多图)?
编辑:
作为对 Ethan 评论的回应:最终输出只是一个 pdf 图像。我可以先创建单独的图,然后将它们放在一起,但是我仍然希望能够相对于彼此定位两个图像。特别是,应该可以“融合”第一个图像的右边界和第二个图像的左边界。在单个多图中,这可以通过修改 tmargins 和 bmargins 来完成。这仍然可以用单独的图像来完成吗?
我是这样理解你的问题的。我猜你只需要自己设置原点和尺寸。您可以使用变量来计算必要的值。
代码:
### multiplot with "insets"
reset session
set key top left
set multiplot
# settings for main plots
set ytics auto
# first plot
s1x = 0.5
s1y = 1.0
set size s1x, s1y
o1x = 0.0
o1y = 0.0
set origin o1x, o1y
plot exp(-x)
# second plot
s2x = 0.5
s2y = 1.0
set size s2x, s2y
o2x = 0.5
o2y = 0.0
set origin o2x, o2y
set ytics auto
plot exp(-2*x)
# settings for insets
set ytics 0.5
# first inset
set size s1x*0.6, s1y*0.5
set origin o1x+s1x*0.4, o1y+s1y*0.5
plot cos(x)
# second inset
set size s2x*0.6, s2y*0.5
set origin o2x+s2x*0.4, o2y+s2y*0.5
plot sin(x)
unset multiplot
### end of code
结果:
您只需要一个多地块环境。您可以通过 手动 将每个图放置在页面上所需的位置来模拟嵌套的多图,例如这样的东西:
set nokey
set multiplot
set size 0.5, 1
set origin 0, 0
plot exp(-x)
set size 0.3, 0.5
set origin 0.2, 0.5
plot cos(x)
set size 0.5, 1
set origin 0.5, 0
plot exp(-2*x)
set size 0.3, 0.5
set origin 0.7, 0.5
plot sin(x)
unset multiplot
结果:
我有两个情节,比如说
set multiplot # First plot with inset
plot exp(-x)
set size 0.6, 0.5
set origin 0.4, 0.5
plot cos(x)
unset multiplot
set multiplot # Second plot with inset
plot exp(-2x)
set size 0.6, 0.5
set origin 0.4, 0.5
plot sin(x)
unset multiplot
这将创建两个单独的图,但我真的想要两个图彼此相邻的单个输出。 作为伪代码,我希望像
set multiplot layout 1,2
set multiplot
plots+insets of first plot here
unset multiplot
set multiplot
plots+insets of second plot here
unset multiplot
unset multiplot
当然,我不认为你可以(轻松地)像那样嵌套多图,所以也许需要一种不同的方法? 重新表述这个问题:如何使用多图创建彼此相邻的不同图,以便其中一些图还包含插图(这本身需要使用多图)?
编辑: 作为对 Ethan 评论的回应:最终输出只是一个 pdf 图像。我可以先创建单独的图,然后将它们放在一起,但是我仍然希望能够相对于彼此定位两个图像。特别是,应该可以“融合”第一个图像的右边界和第二个图像的左边界。在单个多图中,这可以通过修改 tmargins 和 bmargins 来完成。这仍然可以用单独的图像来完成吗?
我是这样理解你的问题的。我猜你只需要自己设置原点和尺寸。您可以使用变量来计算必要的值。
代码:
### multiplot with "insets"
reset session
set key top left
set multiplot
# settings for main plots
set ytics auto
# first plot
s1x = 0.5
s1y = 1.0
set size s1x, s1y
o1x = 0.0
o1y = 0.0
set origin o1x, o1y
plot exp(-x)
# second plot
s2x = 0.5
s2y = 1.0
set size s2x, s2y
o2x = 0.5
o2y = 0.0
set origin o2x, o2y
set ytics auto
plot exp(-2*x)
# settings for insets
set ytics 0.5
# first inset
set size s1x*0.6, s1y*0.5
set origin o1x+s1x*0.4, o1y+s1y*0.5
plot cos(x)
# second inset
set size s2x*0.6, s2y*0.5
set origin o2x+s2x*0.4, o2y+s2y*0.5
plot sin(x)
unset multiplot
### end of code
结果:
您只需要一个多地块环境。您可以通过 手动 将每个图放置在页面上所需的位置来模拟嵌套的多图,例如这样的东西:
set nokey
set multiplot
set size 0.5, 1
set origin 0, 0
plot exp(-x)
set size 0.3, 0.5
set origin 0.2, 0.5
plot cos(x)
set size 0.5, 1
set origin 0.5, 0
plot exp(-2*x)
set size 0.3, 0.5
set origin 0.7, 0.5
plot sin(x)
unset multiplot
结果: