Perspective view


I’m struggling to try to understand how to properly use perspective view (-p) option in GMT5. I’m mainly facing two issues that I’d appreciate some hints on how to handle.

Using the -p option in combination with pscoast shifts the plot in vertically for azimuth not equal to 180 which of course can be compensated for by use of -Y option but it is not clear to me how to properly compute what shift to use. Any hints here would be appreciated (perhaps the shift could be avoided).

The second issue is when combining pscoast with psxyz as it seems that I cannot figure out how to place the map produced by pscoast at Z=0, thus the markers plotted by psxyz do not appear in the proper place but again appear shifted vertically (again this could be compensated for by us of -Y if I knew how to compute the shift, but it seems that this should not be the proper solution).

As an example, the following commands demonstrate both issues:
pscoast $J $R -Ba2f1WESN -A100 -G255/255/204 -S204/229/255 $p -Y-12 -Dh -W1 -N1 -P -K >
psxyz -J -JZ5 $R/0/8 $p -Ss0.4 -W4,red -O << EOF >>
15 61 0

Note the use of -Y-12 in the call to pscoast to compensate for the vertical shift. In the resulting plot the marker created by the call to psxyz is clearly shifted vertically. I noted in the documentation that /zlevel can be added to option -p but this does not solve the shift of the psxyz marker so probably I’m miss-understanding how to use this


I’m not sure why the -p machinery causes that shift. I seem to remember of an issue with -p and having the plot centered on paper. However, if you were using GMT6 and modern mode that shift would have been automatically trimmed of.

Anyway there is an issue with the plotting the z axis for this case. I couldn’t make it be plotted and when I tried the cube, I got this. But note that your point is plot in the correct position.

gmt pscoast -JA0/90/20 -R10/25/55/70/0/8 -JZ5 -A100 -G255/255/204 -S204/229/255 -p155/40 -Dh -W1 -N1 -P -K -Y-12 >
echo 15 61 0 | gmt psxyz -J -JZ -R -p -Ss0.4 -W4,red -Ba2f1 -BWSENZ+b -O >>

Maybe this link in spanish (sorry?) can help you.

For pscoast, you have to add a 0 as a third value (-p155/40/0).
For psxyz, you only need two values (-p155/40).

There are some long-present bugs in -p that is now buried in a very long Issues section on GitHub. We need to address that backlog somehow.

Yes I had some troubles but only with the modern syntax. With classic I had no problems.

@Joaquim Ahh, great, why did I not think about adding -JZ to pscoast (as well as region specs), thanks!

@Esteban, sorry link does not help (do not speak spanish) and adding 0 as zlevel to -p on pscoast neither helps (had tried that already but tried again to be sure). Out of curiosity, in the posted link to the blog post I note that in several of the command options are given on the right hand side of the redirect (>>) after the file name, is this a windows feature? (have never seen it before) Or a typo in the blog post?

Finally a Y shift of map-scale x sin( view-angle) seems to properly counteract the vertical shift imposed by -p

@cpaitor do you try with google translator

“…that in several of the command options are given on the right hand side of the redirect (>>) after the file name, is this a windows feature? (have never seen it before) Or a typo in the blog post?”
It is not a bug. At least in windows you could put some arguments to the right of the output file. I usually put there the arguments that I changed more frequently.

Interesting to know, haven’t been using windows in 10 years (well apart from occasionally trying to help my parents…) and never done any scripting in win. Did use cygwin and gmt for a while before migrating to linux but don’t think the feature were available there either. Anyway, have some colleagues that are using win so knowing about this gives me a better chance of aiding them should I need, so thanks for enlightening me :slightly_smiling_face:

Yes, I know. Windows should be avoid (especially with batch files) but there are so many students/colleagues that use it that it is sometimes necessary to know it.

I highly disagree on that. About 2/3 of GMT users are Win users and batch files, when simple (which now they are most of times) are much handier than bash.

Ofc both batch, bash, csh, etc all stink when compared to clear syntax’s like Julia, but that’s another story.

No no, I certainly don’t think windows should be avoided, sorry if you got that impression. We all have different needs and ambition levels ergo I find it good that there are a multitude of OS out there so that we all have the possibility to choose. My motivation for using Linux may be someone else motivation for not using Linux and that’s fine.

Anyway this is not relevant for this forum so I will stop discussing it further (albeit it being me that sort of initiated the discussion, apologies).