you set everything except 'terminal' and 'output'.
then you do the dummy plot, calculate and set the 'y2range',
set 'terminal' and 'output', plot again.
an example:
reset
set ytics nomirror
set y2tics
set xzeroaxis
set output
# dummy plot
set terminal dumb
plot x-2 axes x1y1, x+5 axes x1y2
# now all the variables are set
# prepare for the real plot
set terminal png
set output "test.png"
# assumption: both yranges contain 'zero'
# otherwise the calculation would be more complicated
yd=GPVAL_Y_MAX-GPVAL_Y_MIN
y2d=GPVAL_Y2_MAX-GPVAL_Y2_MIN
yu=-GPVAL_DATA_Y_MIN/yd
yo=GPVAL_DATA_Y_MAX/yd
y2u=-GPVAL_DATA_Y2_MIN/y2d
y2o=GPVAL_DATA_Y2_MAX/y2d
temp=yo/yu*y2u
y2o=temp>y2o?temp:y2o
temp=yu/yo*y2o
y2u=temp>y2u?temp:y2u
set y2range [-y2u*y2d:y2o*y2d]
# do the real plot
replot
set output
acsg wrote:
>
> Thank you for your reply.
>
> I'm rather new to gnuplot , so I don't quite get what I am supposed to do.
> I am using a script in order to do a plot for some files. The script is as
> follows:
>
>
> for file in $*
> do
> gnuplot <<EOF
> set terminal png
> set output "$1.png"
> set key out vert
> set key bot center
> set title "Packet Loss Estimation for: $1"
> set timefmt "%s"
> set xdata time
> set ylabel "Time gaps (sec)"
> set y2label "Lost Packets"
> set ytics border
> set y2tics border
> set xtics rotate by 90 border offset 0,-4
> set style line 1 lt rgb "gray" lw 7
> set style line 2 lt rgb "black" lw 2
> plot "$1" using 1:2 ls 1 title "Time gaps" axes x1y1 with lines, "$1"
> using 1:3 ls 2 title "Packet Losses" axes x1y2 with impulses
> EOF
> done
>
> I'm still confused as to where am I supposed to create the dummy plot and
> if it will affect the output that I need (in the script, marked as
> $i.png).
>
> Thank you again for your time and help.
>
>
>
--
View this message in context: http://old.nabble.com/Align-zeros-in-Y1-and-Y2-axes-tp31713909p31715337.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|