When plotting with projected coordinates, the longitude cannot exceed 360

Hello, I am one of the GMT users.
My OS is Ubuntu 22.04 LTS, gmt version is 6.3, installed with apt.
When running the following code, I expected a straight line to come out, but…

gmt begin projection png
    gmt set FORMAT_GEO_MAP D MAP_FRAME_TYPE plain
    gmt math -T-1000/1000/1 T = | gmt plot -JM10c -R100/120/-10/10 -BWeSn -Ba5g5 -Wred -fpk
gmt end show


As shown in the figure above, it appeared as a line where clipping occurred periodically. It seems that the gmt automatically truncates when the longitude exceeds 360km in the projected coordinates. I’m wondering if I’m using the wrong option or if it’s really a bug.
Thank you.

Hello, I think you are misunderstanding the way that GMT works with projections. When you specify the projection -JM10c that means that you are going to provide data as latitude and longitude in degrees and want GMT to project that to a Mercator projection. That is why it is wrapping the values that are greater than 360 degrees. If you want to make a map where you have data already in kilometers, then you need to use one of the “Cartesian” projections -JX10c or -Jx. You should read the GMT manual on projections for more details.

Thank you very much for the quick reply. Doesn’t the “-fpk” option directly specify that the input is in projected units (km) rather than degrees? For example, longitude 111.19 is drawn as 1°.

I have never used the -fpk flag, so I am not sure how it is supposed to work. You are asking it to convert “km” in a Mercator projection to degrees for plotting, but you are not specifying the central meridian of the Mercator projection, so it won’t know where your “zero” east location is.