0
votes

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 
1
Can you show the script you're using? Usually you can just re-scale the x-values that you're passing to gnuplot.mgilson
@mgilson I added the source code and clarified. I don't want to change the x-values, because it's an image. I want to change the xtics to correspond to longitude instead of pixel index. Does that make sense?Frank Harris
"I don't want to change the x-values because it's an image". I don't understand that statement. It seems like you could accomplish what you want via some combination of origin, dx and dy keywords to binary. e.g. plot "file" binary array=(100,100) origin=(minx,miny) dx=(maxx-minx)/100 ...mgilson
I fear I'm not phrasing my question very clearly, let me explain with an example. So in this case, minlon=-120.54 and maxlon=-119.94, while the indices of the image I want to plot are minx=0 and maxx=599. Right now, the default behavior makes it so that the xtics are 0,100,200,...,600. I would like the xtics to instead be -120.54,-120.34,...,-119.94. As it is, if I follow your suggestion, I get a blank image because it's looking for pixels that have an index of -120 (at least, that's why I THINK I'm getting a blank image).Frank Harris

1 Answers

0
votes

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