在gnuplot中将y轴添加到多个偏移ytics?

时间:2017-09-07 12:00:08

标签: gnuplot

我正在寻找一段时间来完成我的情节,因为我喜欢它。实际上,根据这里给出的例子,我有一个左y轴和两个右y轴:How to plot multiple y-axes?我得到的信息完成了我想要的工作。但是,在我的情节中,我想在右侧也有第二个y值的y轴。我在四处寻找并找到了这个:multiple Y axis - margin与gnuplot无关。所以现在我不知道怎么做,除了,我将使用矢量并自己构建轴,这可能在定位方面不准确,而不是最好的方法。现在的问题是,如果我可以使用偏移来移动图形的右边界,就像我使用ytics和ylabels一样? gnuplot的帮助没有为“border”提供任何东西,但我也可能在错误的地方搜索。

图片和gnuplot脚本如下。但是,我不允许显示图表,但它不会在这里发挥作用。总结一下:我想最后在我的eps文件中添加红色线,我想知道如果不使用箭头并自己构建它是否可行。此外,我希望这个问题可能与其他人有关,之前没有被问及解决过。否则我的搜索调查很糟糕。提前谢谢。

#!/bin/gnuplot
#
# Tobias Holzmann
# 05.09.2017
# Multiplot for 3 y-axis
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

clear
reset

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

set output "PowerControl.tex"
set terminal epslatex
set key nobox
set ytics out
set y2tics out
set ytics nomirror

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

set style line 1 lw 1.7 lc rgb 'black' ps 0.7 pt 7
set style line 2 lw 1.5 lc rgb 'black'
set style line 3 lw 1.3 lc rgb 'black' dashtype 4

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

set multiplot
set xrange [0:60]
set rmargin screen 0.8
set lmargin screen 0.10

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

set xlabel "Time [s]"
set ylabel "Amount of inserted energy [-]"
set ylabel offset 3,0
set yrange [0:.4]
set ytics \
("None" 0.00, "" 0.05, "" 0.1, "" 0.15, "Moderate" 0.2, \
 "" 0.25, "" 0.3, "" 0.35, "High" 0.4)

unset y2tics

set key at graph 0.95,0.22
set key height 0.3

plot \
"timePower" using 1:2 w lp ls 1 t 'Energy insertion'

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

#unset ytics
#unset xtics
unset ylabel

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

set grid
set y2tics 10
set y2tics out
set y2range [0:80]
set y2label "Von Mises Stress [MPa]"
set key at graph 0.95,0.315
set key height 6

plot \
"timeVonMises" using 1:2 w l ls 2 t 'Von Mises Stress' axis x1y2

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

unset grid
unset ytics
unset ylabel

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

set y2tics 75
set y2range [0:600]
set y2tics offset 8, 0
set y2label "Maximum Temperature [$^{\\circ} $C]" offset 8,0
set key at graph 0.95,0.10
set key height 0.3

plot \
"timeTMax" using 1:($2-273.15) w l ls 3 t 'Temperature' axis x1y2

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

unset multiplot

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Multiplot with Gnuplot without 2nd y-axis

PS:基于我的低声望点数,我不允许直接拍照(不幸的是)。

2 个答案:

答案 0 :(得分:0)

在检查了gnuplot等的联机帮助页后,我认为我不可能拥有它。但是,一个快速简单的解决方法正在使用(如已经提到的do [] {}向量。我的建议如下:

set arrow 1 from graph 1.20,0 to graph 1.20,1 nohead lw 1

do for [i=0:8] {
set arrow from graph 1.20,i/8. to graph 1.21,i/8. nohead lw 1
}

结果如上图(或链接)所示。也许有人可以将它用于人们想要制作的个人情节。如果有人知道更好的解决方案,请告诉我们。

亲切的问候 托拜厄斯

3rd y-axis with arrows and do

答案 1 :(得分:0)

对于最后一个数据集,您可以先绘制数据而不显示y2轴,然后创建一个单独的图表,仅显示y2轴而不显示数据。然后,您可以自由地将两个图相对于彼此放置。重要的是要确保两个图使用相同的高度(可以设置顶部和底部边距)和相同的数值范围(如果您修复范围,这是微不足道的,或者您可以使用writeback / restore如果您想使用y2轴的自动缩放。

示例:

reset
set multiplot

# first, draw the graph without y2 axis
set tmargin 1
set bmargin 3
set rmargin 20

set xtics nomirror
unset ytics
unset y2tics
unset key
set border 1                 # draw only the bottom border (the x axis)
set y2range [] writeback     # use autoscaling for y2 and store the range
plot sin(x) axes x1y2


# now draw only the y2 axis, with the range from the previous plot
set y2range restore
set rmargin 10
set border 8     # draw only the right border (the y2 axis)
unset xtics
set y2tics
plot 1/0 axes x1y2

unset multiplot

给出

enter image description here