gnuplot - 使用 gnuplot 在图的左侧添加多个 yrange
问题描述
是否可以使用 gnuplot 在绘图的左侧添加超过一个 yrange?请看下面的链接图。
理想情况下,我需要 yrange 命令,例如 y3range、y4range 等。
使用multiplot
我无法得到我想要的。
set multiplot
set lmargin at scr 0.2
set bmargin at scr 0.1 # fix bottom margin
set grid
set y2range [0:20]
plot x, 2*x axes x1y2 # this is your actual plot
unset grid
set lmargin at scr 0.2
set bmargin at scr 0.15 # fix bottom margin
set yrange [0:20] # set yrange to the same as y2 in the first plot
set border 0 # switch off all borders except the left
unset xtics # switch off the stray xtics
plot -1000 notitle # plot something outside of the y(2)range
unset multi
解决方案
您必须相应地设置 yrange,以使 ytics 和网格很好地对齐。向 ytics 添加偏移量以调整距离。检查help xtics
。
代码:
### multiple axes
reset session
# common settings for all (sub-)plots
set lmargin at screen 0.15
set bmargin at screen 0.12
set xlabel "my x-title"
set xrange[0:3000]
set grid
set ytics font ",8"
myOffsetY = 0.7
set multiplot
set ylabel "my 1st y-label" tc rgb "red" offset -2,0
set yrange [-10:6]
set ytics -10,2 tc rgb "red" offset 0,0
plot 0.001*x-10 w l lc rgb "red" notitle
set xlabel " "
unset xtics
unset grid
set ylabel "my 2nd y-label" tc rgb "green" offset 2,0
set yrange [-10.0:-2.0]
set ytics -10, 1 tc rgb "green" offset 0,-myOffsetY
set format y "%.1f"
plot 0.002*x -10w l lc rgb "green" notitle
set ylabel "my 3rd y-label" tc rgb "blue" offset -4,0
set yrange [-60:20]
set ytics -60, 10 tc rgb "blue" offset 0,myOffsetY
set format y "%.0f"
plot 0.003*x-10 w l lc rgb "blue" notitle
unset multiplot
### end of code
推荐阅读
- html - 从 html 列表中随机选择一项
- c++ - 如何将子组件函数重定向到 C++ 中的子函数?
- c++ - 功能模板的特化,不改变其原型
- c++ - 您可以转发声明未声明模板类的显式特化吗?
- r - 如何链接 ifelse?
- javascript - 我正在制作的网站导航栏的小 CSS 错误
- flutter - 我们如何编写一个自定义地图,其中每个街区(房子)都可以在颤动中点击?
- node.js - 如何解决 npm 错误“npm ERR!errno -4058”“nom ERR!enoent”
- kotlin - 如何在 Kotlin 中创建具有特定类型参数的“类”实例?
- flutter - Flutter - 无法将类字段传递给子组件