How to make a contour plot via GMT 5

I would like to create a contour plot. I have a .txt file with 3 columns (1st with Latitude, 2nd with longtitude and 3rd with several values from 1-20). I would like to create a contour plot (XYZ) for the 3rd column.

I am using these commands but no use:

**xyz2grd data.txt **
grd2cpt data.grd -Crainbow -S0/1.5/0.01 > data.cpt
grdimage data.grd -R -Cdata.cpt -B0.1f0.1 -JM18 -E100 -X1.5 -P -K > data.ps
pscoast -R -JM -B0.1f0.1 -N1to -Df -W3/0/0/0 -O -K >> data.ps
grdcontour data.grd -C0.01 -A0.01t -JM -W0.5p/0/0/0 -O >> data.ps

gsview64 data.ps

Could you please help me?

I am using GMT 5 version

A couple of points to help you follow up on this:

  1. GMT 5? Please update to GMT 6.4 as we would not be able to fix any problems in an ancient GMT version. Although that is probably not the source of the problem. If it ends up being a problem in 6.4 (which I very much doubt) then we will of course address it.

  2. While your GMT version might be ancient, your command syntax looks even older (GMT3?). Again, should not matter but be aware that you are a decade behind.

  3. From gsview64 I am guessing this is Windows.

  4. Things going wrong 1: When you ran xyz2grd on data.txt, did you use -i1,0,2 or -: to fix the backwards lat, lon order?

  5. Things going wrong 2: If z goes 1-20, how about makecpt -Crainbow -T1/20 > data.cpt ?

Please check what is appropriate and report back.

Yes I am using GMT5 in windows. I found these commands, but I do not know how to syntax them . That’s why I am asking for help…
What did you mean by “ix the backwards lat, lon order?”

You said you had lat, lon, depth but GMT expects lon, lat, depth, (i.e., x,y,z) hence you need to switch things around with either -: or using -i.

Sorry, but I am confused. Could you please tell me what should I do in order to plot the contours in GMT?
I am difficult to syntax the above mentioned commands…

Thank you in advance

Maybe something like this:

gmt xyz2grd yourtable.txt -Ryourregion -Iyourincrement -: -Gdata.grd
gmt makecpt -Crainbow -T0/20/1 > data.cpt
gmt grdimage data.grd -R -Cdata.cpt -B0.1f0.1 -JM18 -E100 -X1.5 -P -K > data.ps
gmt pscoast -R -JM -B0.1f0.1 -N1to -Df -W3/0/0/0 -O -K >> data.ps
gmt grdcontour data.grd -C0.01 -A0.01t -JM -W0.5p/0/0/0 -O >> data.ps

???

Is there any way to use pscontour command ?
I am using this command but no use…

pscontour data.txt -R18/30/30/42 -Jl18/24/0.5i -Ctopo.cpt -W0.5p > data.ps

Could you please help me?

Looks good to me. Perhaps your data and CPT do not match. Other that that we have no information to guess what is going wrong. Please show the result of

gmt info data.txt

and post it here.

I am uploading the results of my command output.

I am waiting for your reply.

Thank you in advance.

So -Jl requires 5 arguments and you are giving it 3 and you want me to tell you that 3 is not 5? Just read the error message and fix your projection setting.

ok… An another way according to your suggestions is the following commands:

xyz2grd data.txt -R18/30/30/42 -I -: -Gdata.grd
makecpt -Crainbow -T0/20/1 > data.cpt
grdimage data.grd -R -Cdata.cpt -B0.1f0.1 -JM18 -E100 -X1.5 -P -K > data.ps
pscoast -R -JM -B0.1f0.1 -N1to -Df -W3/0/0/0 -O -K >> data.ps
grdcontour data.grd -C0.01 -A0.01t -JM -W0.5p/0/0/0 -O >> data.ps

gsview64 data.ps

but it is not working. I am attaching the results of the run

I am asking you because it is very difficult for me to make it . Could you please help me?

But you are not even giving xyz2grd a grid increment but just a blank -I and you are getting a specific error message back! I cannot do your work for you, but we can offer help. But if the error message is staring you in the face and you do not act on it, what am I supposed to do? I do not know your data, I do not know what is a sensible grid interval, but you should. Try -I1 for starters (1x1 degree grid). The rest of the errors are due to the first error.