質問

I am trying to break my gnuplot down into a stacked plot for better readability. I'd like the horsepower and torque data to be on the same plot and the other data to be separately displayed on stacked plots below this--all lined up by the same X axis. Sort of like this:

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

I've tried variations of multiplot but can't seem to get things to display properly. Here's the nonmultiplot version:

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)'
役に立ちましたか?

解決

Here is how you can get the kind of plot you referenced with the first link.

To have horsepowers and torque on the same plot but with different axes, use:

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)'

To stack the other data plot below, you need the multiplot mode. In order to have equal margins on the left and right, although the upper plot has tics and labels on the y2-axis, you must use explicit margins instead of the automatically computed:

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

I left out all your scalings and test functions to make the structur more clear. If the upper and lower plots have different number of digits on the y-axis, you may need to adapt one of the ylabels by an offset to align with the other, e.g. set ylabel 'ylabel' offset -1. The offset number is given in terms of character widths.

I set the left and right margin also in terms of character widths, and you may need to adapt the values. For the bottom margin of the upper plot and top margin of the lower plot I used fractional screen coordinates.

BTW: If you really need to use a bitmap terminal, then use pngcairo instead of png. Preferably, you should use e.g. pdfcairo or a similar vector-based output format.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top