【问题标题】:gnuplot complex stacked plotgnuplot 复杂堆积图
【发布时间】:2013-10-10 06:11:04
【问题描述】:

我正在尝试将我的 gnuplot 分解为堆叠图以提高可读性。我希望马力和扭矩数据在同一个图上,而其他数据分别显示在下面的堆叠图上——所有这些都由同一个 X 轴排列。有点像这样:

http://abloriginalparts.com/pb/wp_2f5b1e2e/images/img1226948967fe0ad9dc.JPG

我尝试了多图的变体,但似乎无法正确显示内容。这是非多情节版本:

http://i1347.photobucket.com/albums/p715/balaguru42/dyno_zpsc0213c60.png

set term png
set y2range [-5:40]
set y2tics
set ytics nomirror
set xlabel 'RPM'
set ylabel 'Torque/Power'
set y2label 'AFR/Timing/Boost/MAF'
set key bottom
InRange(x)=((x>0) ? x : 1/0)
ConvertMap(x)=(x-1) * 14.5
ConvertMapDelta(x)=x * 14.5
ConvertMaf(x)=x * 3
ConvertMafDelta(x)=x * 3
set output "output/dyno.png"
plot \
    "output/dyno.dat" using 1:(InRange($2)):3 \
        with yerrorbars title 'Torque (ft-lbs)', \
    "output/dyno.dat" using 1:(InRange($4)):5 \
        with yerrorbars title 'Power (hp)', \
    "output/dyno.dat" using 1:(InRange($6)):7 \
        with yerrorbars axes x1y2 title 'AFR', \
    "output/dyno.dat" using 1:(InRange($8)):9 \
        with yerrorbars axes x1y2 title 'Ignition (deg)', \
    "output/dyno.dat" using 1:(InRange($10)):11 \
        with yerrorbars axes x1y2 title 'Intake (deg)', \
    "output/dyno.dat" using 1:(InRange(ConvertMap($12))):(ConvertMapDelta($13)) \
        with yerrorbars axes x1y2 title 'Boost (psi)', \
    "output/dyno.dat" using 1:(InRange(ConvertMaf($16))):(ConvertMafDelta($17)) \
        with yerrorbars axes x1y2 title 'MAF (V x 3)'

【问题讨论】:

    标签: plot gnuplot stacked


    【解决方案1】:

    您可以通过以下方式获得您在第一个链接中引用的那种情节。

    要在同一图上使用不同的轴来获得马力和扭矩,请使用:

    set ytics nomirror
    set y2tics
    set ylabel 'horse power (hp)'
    set y2label 'torque (ft-lbs)'
    set style data yerrorbars
    plot 'output/dyno.dat' using 1:4:5  title 'Power (hp)',\
         '' using 1:2:3 title 'Torque (ft-lbs)'
    

    要堆叠下面的其他数据图,您需要multiplot 模式。为了使左右边距相等,尽管上图在y2 轴上有抽动和标签,但您必须使用显式边距而不是自动计算的边距:

    set ytics nomirror
    set y2tics
    set ylabel 'horse power (hp)'
    set y2label 'torque (ft-lbs)'
    set format x ''
    set xrange[1000:7000]
    
    set style data yerrorbars
    
    set multiplot
    
    set lmargin 8
    set rmargin 8
    set tmargin 1
    set bmargin at screen 0.4
    
    plot 'output/dyno.dat' using 1:4:5  title 'Power (hp)',\
         '' using 1:2:3 title 'Torque (ft-lbs)'
    
    unset y2tics
    unset y2label
    set format x
    set xlabel 'RPM'
    set ylabel 'AFR/Timing/Boost/MAF'
    
    set tmargin at screen 0.38
    set bmargin 4
    plot 'output/dyno.dat' using 1:6:7 title 'AFR'
    
    unset multiplot
    

    我省略了你所有的缩放和测试函数,以使结构更清晰。如果上图和下图在y 轴上的位数不同,您可能需要通过offset 调整ylabels 之一以与另一个对齐,例如set ylabel 'ylabel' offset -1offset 数字是根据字符宽度给出的。

    我还根据字符宽度设置了左右边距,您可能需要调整这些值。对于上图的下边距和下图的上边距,我使用了分数屏幕坐标。

    顺便说一句:如果你真的需要使用位图终端,那么使用pngcairo 而不是png。最好,您应该使用例如pdfcairo 或类似的基于矢量的输出格式。

    【讨论】:

      猜你喜欢
      • 2017-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-22
      相关资源
      最近更新 更多