Frank Harris
Frank Harris

Reputation: 305

gnuplot add scale and offset to xtics?

I'm plotting a 600px*600px image in gnuplot, and I would like to have the xtics correspond to a different coordinate system than the pixel system. as it is, the xtics go 0, 100, 200, ..., 500, 600. I would like to make them be at the same place, but have different values. Is there a way to make it so that the tics are uniformly modified, like, xtic[i] = (xtic[i]*c1) + c2?

EDIT: Here's my code. Also, I should clarify that what I'm trying to do is have the xtics and ytics correspond to longitude and latitude specifically. So for instance, I would like to add in a transformation such that xtic=0 -> xtic=$minlat, and xtic=$maxx -> xtic=$maxlat.

#!/bin/sh                                                                               

inputfilename=$1
outputfilename=$2
minlat=$3
maxlat=$4
minlon=$5
maxlon=$6
imagexsize=$7
imageysize=$8
maxx=$(($imagexsize - 1))
maxy=$(($imageysize - 1))

windowxsize=$(($imagexsize+5+5))
windowysize=$(($imageysize+5+5))

imagename=${inputfilename%.*}

gnuplot <<EOF                                                                           

set terminal png size $windowxsize,$windowysize                                         
unset key                                                                               
unset colorbox                                                                          
set output "$outputfilename"                                                            
set lmargin 5                                                                           
set bmargin 5                                                                           
set rmargin 5                                                                           
set tmargin 5                                                                           
set size square                                                                         
set xrange [0:${maxx}]                                                                  
set yrange [0:${maxy}]                                                                  
set palette grey                                                                        
set label "$imagename" at screen 0.3,0.95                  
plot "$inputfilename" binary array=${imagexsize}x${imageysize} format='%ushort' with image                                                                                     

EOF 

Upvotes: 0

Views: 811

Answers (1)

Scott Smedley
Scott Smedley

Reputation: 1867

You can accomplish this quite easily by adding a 'using' argument to your 'plot' command.

Here's an example with an added offset of 10 & scale of 0.5:

plot '-' using (($1+10)/2):(($2+10)/2) with linespoints
1 2
3 4
5 6
e

Upvotes: 0

Related Questions