如何使用GNUPLOT在左侧绘制几个Y轴

发布于 2025-01-27 21:33:52 字数 331 浏览 1 评论 0原文

我正在绘制与此处相同的绘图如何绘制多个Y-axes? 。但我也希望它们看起来像下图。有了其他线条和抽动,我该怎么做? 想要“

I am plotting same plot as from here How to plot multiple y-axes?. But also i would like them to look like in the image below. With additional lines and tics, how can i do it?
What I want

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

霓裳挽歌倾城醉 2025-02-03 21:33:52

如您所链接的答案中所述,您可以在Multiplot环境中相互绘制许多图。
因此,在这里,您在彼此之间绘制6个

  • 图1、2、3的数据/功能
  • 图4、5、6的彩色轴
  • 和绘图6,以及所有内容的钥匙

,以获取 所有内容我建议将图和“外部”轴相同的比例存储在变量y10,Y11,Y1D,....中,以便您必须更改仅在一个位置。

脚本:


reset session

set key opaque box noautotitle

set multiplot
    set margins screen 0.3, screen 0.95, screen 0.95, screen 0.1   # l,r,t,b
    
    # first plot
    set xrange[0:10]
    set xtics 2
    y10 = -1.2
    y11 =  1.2
    y1d =  0.4
    set yrange [y10:y11]
    set ytics y1d
    set format y ''     # no ytic labels
    set grid x,y
    plot sin(x) lc "red"

    # second plot
    set border 0        # no border
    unset tics          # no tics
    unset grid          # no grid
    y20 = -3.0
    y21 =  3.0
    y2d =  1.0
    set yrange [y20:y21]
    plot 3*cos(x) lc "green"

    # third plot
    y30 = -1.5
    y31 =  1.5
    y3d =  0.5
    set yrange [y30:y31]
    plot 3*sin(x)*cos(x) lc "blue"

    # plot for axis 1
    set lmargin screen 0.27
    set border 2 lc "red" lw 2
    set ylabel "Voltage" tc "red" offset 1.5,0
    set yrange [y10:y11]
    set format y
    set ytics y1d nomirror
    plot NaN

    # plot for axis 2
    set lmargin screen 0.17
    set border 2 lc "green" lw 2
    set ylabel "Current" tc "green" offset 0.5,0
    set yrange [y20:y21]
    set ytics y2d
    plot NaN
    
    # plot for axis 3 and key
    set lmargin screen 0.08
    set border 2 lc "blue" lw 2
    set ylabel "Power" tc "blue" offset 1,0
    set yrange [y30:y31]
    set ytics y3d
    plot NaN w l lc "red"   ti "sin(x)", \
         NaN w l lc "green" ti "3*cos(x)", \
         NaN w l lc "blue"  ti "3*sin(x)*cos(x)"
unset multiplot
### end of script

结果:

”

As mentioned in the answer you linked, you can plot many plots on top of each other in the multiplot environment.
So, here you are plotting 6 plots on top of each other

  • plot 1, 2, 3 for the data/functions
  • plot 4, 5, 6 for the colored axes
  • and plot 6 as well for the key on top of everything

In order to get the same scale for the plot and the "external" axes I would recommend to store the ranges and step sizes in the variables y10,y11,y1d, ...., such that you have to change the values only at one location.

Script:


reset session

set key opaque box noautotitle

set multiplot
    set margins screen 0.3, screen 0.95, screen 0.95, screen 0.1   # l,r,t,b
    
    # first plot
    set xrange[0:10]
    set xtics 2
    y10 = -1.2
    y11 =  1.2
    y1d =  0.4
    set yrange [y10:y11]
    set ytics y1d
    set format y ''     # no ytic labels
    set grid x,y
    plot sin(x) lc "red"

    # second plot
    set border 0        # no border
    unset tics          # no tics
    unset grid          # no grid
    y20 = -3.0
    y21 =  3.0
    y2d =  1.0
    set yrange [y20:y21]
    plot 3*cos(x) lc "green"

    # third plot
    y30 = -1.5
    y31 =  1.5
    y3d =  0.5
    set yrange [y30:y31]
    plot 3*sin(x)*cos(x) lc "blue"

    # plot for axis 1
    set lmargin screen 0.27
    set border 2 lc "red" lw 2
    set ylabel "Voltage" tc "red" offset 1.5,0
    set yrange [y10:y11]
    set format y
    set ytics y1d nomirror
    plot NaN

    # plot for axis 2
    set lmargin screen 0.17
    set border 2 lc "green" lw 2
    set ylabel "Current" tc "green" offset 0.5,0
    set yrange [y20:y21]
    set ytics y2d
    plot NaN
    
    # plot for axis 3 and key
    set lmargin screen 0.08
    set border 2 lc "blue" lw 2
    set ylabel "Power" tc "blue" offset 1,0
    set yrange [y30:y31]
    set ytics y3d
    plot NaN w l lc "red"   ti "sin(x)", \
         NaN w l lc "green" ti "3*cos(x)", \
         NaN w l lc "blue"  ti "3*sin(x)*cos(x)"
unset multiplot
### end of script

Result:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文