Skip to content

Double frame on grdview perspective plot #4181

Closed

Description

@weiji14

Description of the problem

There appears to be a double-frame on the x and y-axis when making a perspective plot using grdview with the -Jz flag. Originally detected at GenericMappingTools/pygmt#589 (comment).

Actual (incorrect) plot Expected (correct) plot
test_grdview_with_perspective_and_zaxis_frame-expected test_grdview_with_perspective_and_zaxis_frame

Full script that generated the error

gmt begin doubleframe png
    gmt grdcut @earth_relief_01d_g -R-116/-109/-47/-44 -Gtempgrid.nc
    gmt grdview tempgrid.nc -p225/30 -Jz0.005 -Bzaf -Vd
gmt end

Full error message

Details
gmt [DEBUG]: Obtained the ppid from parent: 176
gmt [DEBUG]: Enter: gmtinit_new_GMT_ctrl
gmt [DEBUG]: GMT->session.SHAREDIR = /srv/conda/envs/notebook/share/gmt
gmt [DEBUG]: GMT->session.HOMEDIR = /home/jovyan
gmt [DEBUG]: GMT->session.USERDIR = /home/jovyan/.gmt [created]
gmt [DEBUG]: GMT->session.CACHEDIR = /home/jovyan/.gmt/cache [created]
gmt [DEBUG]: GMT: 0. Will try to find subdir=postscriptlight stem = PSL_custom_fonts suffix=.txt
gmt [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
gmt [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /home/jovyan/.gmt
gmt [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /home/jovyan/.gmt/postscriptlight
gmt [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /srv/conda/envs/notebook/share/gmt/postscriptlight
gmt [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /srv/conda/envs/notebook/share/gmt
gmt [DEBUG]: GMT: 6. gmt_getsharepath failed
gmt [DEBUG]: Map distance calculation will be Cartesian
gmt [DEBUG]: Exit:  gmtinit_new_GMT_ctrl
gmt [DEBUG]: Enter: New_PSL_Ctrl
gmt [DEBUG]: Exit:  New_PSL_Ctrl
gmt [DEBUG]: Enter: gmt_manage_workflow
gmt [DEBUG]: GMT now running in modern mode [Session ID = 176]
gmt [DEBUG]: Exit : gmt_manage_workflow
gmt [DEBUG]: Enter: PSL_beginsession
gmt [DEBUG]: Exit : PSL_beginsession
gmt [DEBUG]: Enter: PSL_setdefaults
gmt [DEBUG]: Exit : PSL_setdefaults
gmt [DEBUG]: Enter: gmtlib_io_init
gmt [DEBUG]: Exit : gmtlib_io_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: Enter: gmt_reload_settings
gmt [DEBUG]: The PROJ_GEODESIC set to Vincenty
gmt [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0
gmt [DEBUG]: Reading GMT Default parameters from file: /home/jovyan/.gmt/sessions/gmt_session.176/gmt.conf
gmt [DEBUG]: Exit:  gmt_reload_settings
gmt [DEBUG]: Enter: gmtlib_plot_C_format
gmt [DEBUG]: Exit:  gmtlib_plot_C_format
gmt [DEBUG]: Enter: gmtinit_get_history
gmt [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: Exit:  gmtinit_get_history
gmt [DEBUG]: Initialize FFTW with 6 threads.
gmt [DEBUG]: GMT_Create_Session initialized GMT structure
gmt [DEBUG]: Loading core GMT shared library: libgmt.so
gmt [DEBUG]: Shared Library # 0 (core). Path = libgmt.so
gmt [DEBUG]: Loading GMT plugins from: /srv/conda/envs/notebook/lib/gmt/plugins
gmt [DEBUG]: Shared Library # 1 (supplements). Path = /srv/conda/envs/notebook/lib/gmt/plugins/supplements.so
gmt [DEBUG]: GMT now running in modern mode [Session ID = 176]
gmt [DEBUG]: Use PS filename /home/jovyan/.gmt/sessions/gmt_session.176/gmt_0.ps-
gmt [DEBUG]: gmtinit_get_current_panel: No current panel selected so not in subplot mode
gmt [DEBUG]: Modern mode: Added -R to options since history is available.
gmt [DEBUG]: Modern: Adding -JX15c to options since there is no history available.
gmt [DEBUG]: Revised options: tempgrid.nc -p225/30 -Jz0.005 -Bzaf -Vd -R -JX15c
grdview [DEBUG]: History: Process -p225/30
grdview [DEBUG]: History: Process -Jz0.005
grdview [DEBUG]: History: Process -R
grdview [DEBUG]: History: Process -JX15c
grdview [DEBUG]: gmt_get_filename: In: -116/-109/-47/-44 Out: -116/-109/-47/-44
grdview [DEBUG]: Look for file -116/-109/-47/-44 in /home/jovyan/.gmt
grdview [DEBUG]: Look for file -116/-109/-47/-44 in /home/jovyan/.gmt/cache
grdview [DEBUG]: Look for file -116/-109/-47/-44 in /home/jovyan/.gmt/server
grdview [DEBUG]: Got regular w/e/s/n for region (-116/-109/-47/-44)
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: Found readable file tempgrid.nc
grdview [DEBUG]: Replace file tempgrid.nc with path tempgrid.nc
grdview [DEBUG]: Replace file tempgrid.nc with tempgrid.nc
grdview [DEBUG]: Local file /home/jovyan/.gmt/server/gmt_data_server.txt found
grdview [DEBUG]: File /home/jovyan/.gmt/server/gmt_data_server.txt less than 24 hours old, refresh is premature.
grdview [DEBUG]: Load contents from /home/jovyan/.gmt/server/gmt_data_server.txt
grdview [DEBUG]: Local file /home/jovyan/.gmt/server/gmt_hash_server.txt found
grdview [DEBUG]: File /home/jovyan/.gmt/server/gmt_hash_server.txt less than 24 hours old, refresh is premature.
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: Found readable file tempgrid.nc
grdview [DEBUG]: Replace file tempgrid.nc with path tempgrid.nc
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: Found readable file tempgrid.nc
grdview [DEBUG]: Replace file tempgrid.nc with path tempgrid.nc
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: Found readable file tempgrid.nc
grdview [DEBUG]: Object ID 0 : Registered Grid File tempgrid.nc as an Input resource with geometry Surface [n_objects = 1]
grdview [DEBUG]: gmtapi_begin_io: Input resource access is now enabled [container]
grdview [DEBUG]: gmtapi_import_grid: Passed ID = 0 and mode = 1
grdview [DEBUG]: Found readable file tempgrid.nc
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: Call gmtgrdio_doctor_geo_increments on a geographic grid
grdview [DEBUG]: Geographic input grid, longitudes span less than 360
grdview [DEBUG]: GMT_End_IO: Input resource access is now disabled
grdview [DEBUG]: Projected values in meters: -3.5 3.5 -47 -44
grdview [DEBUG]: Auto-frame interval for axis 2 item 0: d = 200  f = 100
grdview [INFORMATION]: Auto-frame interval for z-axis (item 0): a200f100
grdview [INFORMATION]: Map scale is 0.000466667 km per cm or 1:46.6667.
grdview [INFORMATION]: Processing shape grid
grdview [DEBUG]: gmtapi_begin_io: Input resource access is now enabled [container]
grdview [DEBUG]: gmtapi_import_grid: Passed ID = 0 and mode = 2
grdview [INFORMATION]: Reading grid from file tempgrid.nc
grdview [DEBUG]: packed z-range: [-3606.5,-2614.5]
grdview [DEBUG]: Geographic input grid, longitudes span less than 360
grdview [DEBUG]: Chosen boundary condition for all edges: geographic
grdview [INFORMATION]: Set boundary condition for all edges: natural
grdview [INFORMATION]: Set boundary condition for left   edge: natural
grdview [INFORMATION]: Set boundary condition for right  edge: natural
grdview [INFORMATION]: Set boundary condition for bottom edge: natural
grdview [INFORMATION]: Set boundary condition for top    edge: natural
grdview [DEBUG]: GMT_End_IO: Input resource access is now disabled
grdview [DEBUG]: Octant 4 (az = 153.435) one = 1
grdview [DEBUG]: Outer loop over x doing 6:-1:-1
grdview [DEBUG]: Inner loop over y doing 1:1:4
grdview [INFORMATION]: Start creating PostScript plot
grdview [DEBUG]: Running in PS mode modern
grdview [DEBUG]: Use PS filename /home/jovyan/.gmt/sessions/gmt_session.176/gmt_0.ps-
grdview [DEBUG]: Create hidden PS file /home/jovyan/.gmt/sessions/gmt_session.176/gmt_0.ps-
grdview [DEBUG]: No figure file /home/jovyan/.gmt/sessions/gmt_session.176/gmt.figures - nothing to do
grdview [DEBUG]: Got session name as doubleframe and default graphics formats as png
grdview [INFORMATION]: Do mesh plot with mesh color white
grdview [DEBUG]: Current size of half-baked PS file /home/jovyan/.gmt/sessions/gmt_session.176/gmt_0.ps- = 22543.
grdview [DEBUG]: gmtlib_garbage_collection: Destroying object: C=0 A=0 ID=0 W=Input F=Grid M=File S=Used P=56499f4a5350 N=tempgrid.nc
grdview [DEBUG]: GMTAPI_Garbage_Collection freed 1 memory objects
grdview [DEBUG]: gmtlib_unregister_io: Unregistering object no 0 [n_objects = 0]
grdview (gmtlib_free_tmp_arrays): tried to free unallocated memory
gmt [DEBUG]: Entering GMT_Destroy_Session
gmt [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0

System information

I've reproduced this both on my personal computer and on the try-gmt.

  • Operating system: Linux-4.19.112+-x86_64-with-glibc2.10
  • GMT version (gmt --version): 6.1.1

Activity

  1. joa-quim commented on Sep 7, 2020

    @joa-quim
    Member

    You can avoid it with

    gmt grdview @earth_relief_01d_g -R-116/-109/-47/-44 -p225/30 -JZ5 -Bzaf --MAP_FRAME_TYPE=plain -pdf map
    
  2. seisman commented on Sep 7, 2020

    @seisman
    Member

    The "double frame" is actually the frame for geographic projections (i.e., the fancy frame). If you add -Bxaf -Byaf to the command, it would be more clear:

    image

    The debug message from @weiji14 says:

    gmt [DEBUG]: Revised options: tempgrid.nc -p225/30 -Jz0.005 -Bzaf -Vd -R -JX15c
    

    it's unclear to me why GMT chooses -JX15c for a geographic grid.

  3. joa-quim commented on Sep 7, 2020

    @joa-quim
    Member

    it's unclear to me why GMT chooses -JX15c for a geographic grid.

    It's the poor man's choice. Alternative would be to give the right projection for the given region. Doable but never done.

  4. weiji14 commented on Sep 7, 2020

    @weiji14
    MemberAuthor

    Ok, put it down as user error for now (setting a projection like -JT-112.5/45.5 works). Still think the zebra stripes should show up properly though instead of having a double lined frame, or that we just plot a single lined frame.

  5. joa-quim commented on Sep 7, 2020

    @joa-quim
    Member

    Agree. It's a mild bug

  6. PaulWessel commented on Sep 9, 2020

    @PaulWessel
    Contributor

    Not sure what you expect here. There is only -Bzaf given, right? So nothing for x-y. It cannot draw checker-board without knowing or setting increments, but no -B was given. So what it did was basically -B0. When that happens I totally agree that the double lines are not helpful, so it could switch to a plain frame in that case when no increments are set.

  7. seisman commented on Sep 9, 2020

    @seisman
    Member

    I actually expect no X and Y frames here, because not -Bxaf and -Byaf are given.

    BTW, adding -B0 to the grdview command gives me a plain frame.

  8. PaulWessel commented on Sep 9, 2020

    @PaulWessel
    Contributor

    Yes, I can go with that, I was just assuming we have to do some backwards compatibility here by drawing that -B0. But I would be fine and happier with just the z-axis as requested.

  9. seisman commented on Sep 9, 2020

    @seisman
    Member

    Ping @weiji14.

  10. weiji14 commented on Sep 9, 2020

    @weiji14
    MemberAuthor

    I think it would look weird with just the z-axis plotted and no x and y frames (maybe someone would plot it that way?), but happy to go with it (just z-axis plotted). Anything is better than the strange double frame really.

  11. joa-quim commented on Sep 9, 2020

    @joa-quim
    Member

    Remember that we have MAP_FRAME_AXES defaulting to WSEN so this case has to plot those axes but in plain. In the unlikely case the user won't them, he can always do --MAP_FRAME_AXES=Z

  12. PaulWessel commented on Sep 9, 2020

    @PaulWessel
    Contributor

    Or -B+n I think.

  13. seisman commented on Sep 9, 2020

    @seisman
    Member

    Or -B+n I think.

    No, -Bzaf -B+n doesn't plot the Z axis.

    Remember that we have MAP_FRAME_AXES defaulting to WSEN so this case has to plot those axes but in plain. In the unlikely case the user won't them, he can always do --MAP_FRAME_AXES=Z

    For 2D maps, the frames are not plotted unless -B, -Bx or -By is given. However, for the 3D case, giving -Bz only also plots the X and Y axes seems weird to me.

  14. PaulWessel commented on Sep 10, 2020

    @PaulWessel
    Contributor

    Yes, it breaks the logic. -Bz should not magically also turn on horizontal frames I think. That is the error here.

  15. added a commit that references this issue on Oct 6, 2020
    77d2c93
  16. 7 remaining items

  17. PaulWessel commented on Oct 6, 2020

    @PaulWessel
    Contributor

    I am totally confident in that is what we meant, yes. But

    gmt basemap -R0/5/0/5/0/1 -JX3i -JZ1i -B0 -p170/35 -pdf map

    gives that z-stick.

  18. PaulWessel commented on Oct 6, 2020

    @PaulWessel
    Contributor

    I am learning that if I turn the z-axis off then the map title is plotted as 2-D instead of in-plane 3-D. So while the above command no longer has a stick. Compare these:

    In master, running gmt basemap -R0/5/0/5/0/1 -JX3i -JZ1i -B0 -B+tTITLE -p170/35 -png master gives

    master

    while in my branch that lets -B0 only set x/y frame the same command looks like this:

    branch

    In that branch, I can get the first plot by adding -Bz0. As you can see, a true 3-D plot places a 2-D title while a perspective 2-D plot gets a title in the same perspective. Might also want to document taht, but I think the branch is better, no? What does @seisman think? I should add that perhaps the real problem is that -JZ is being used but nothing is plotted in z. So perhaps master is correct in that sense. Yet, if I take out -JZ and run master I get a 2-D title:

    master

  19. joa-quim commented on Oct 6, 2020

    @joa-quim
    Member

    Having the z stick with -JZ1i -B0 seems correct because there is a -JZ. The title is more confuse. Middle plot seems more correct.

  20. PaulWessel commented on Oct 6, 2020

    @PaulWessel
    Contributor

    I agree. So we have these rules:

    1. A 3-D plot is one where -p and -Jz|Z are given and they imply a 3-D basemap and a conventional flat 2-D title
    2. A perspective 2-D plot has -p but no -Jz|Z and implies a 2-D basemap and a perspective 2-D title
    3. The -B0 always apply to the x-y frame but also applies to the z-axis if a true 3-D plot.
  21. joa-quim commented on Oct 7, 2020

    @joa-quim
    Member

    Yes, seems to cover all cases.

  22. seisman commented on Oct 7, 2020

    @seisman
    Member

    #4293 still doesn't fix the issue, right?

  23. reopened this on Oct 7, 2020
  24. seisman commented on Oct 7, 2020

    @seisman
    Member

    Trying the latest master branch.

    The following result doesn't make sense. Here I give -Bx -By, but the Y annotations and ticks are not shown.

    gmt basemap -R0/5/0/5/0/1 -JX3i -JZ1i -B+tTITLE -p170/35 -png map -Bx -By -Bz
    

    image

  25. PaulWessel commented on Oct 7, 2020

    @PaulWessel
    Contributor

    So in the highest level of parsing I know we look (in modern mode only) for options like plain -B and we append to make it -Baf. I probably did not check for them all individually so will do that later today).

  26. PaulWessel commented on Oct 7, 2020

    @PaulWessel
    Contributor

    No, I have checks for those cases and they should all end up as -Bxaf -Byaf and -Bzaf. So then the question is what happens next in the auto-interval section.

  27. PaulWessel commented on Oct 7, 2020

    @PaulWessel
    Contributor

    After -Bx is parsed, GMT->current.map.frame.set is true and -By is not processed, only -Bz. I think set needs to be set[GMT_X|Y|Z] so we have more control here.

  28. PaulWessel commented on Oct 12, 2020

    @PaulWessel
    Contributor

    Note: This has been fixed in PR #4274 and will go away once that branch is merged.

  29. PaulWessel commented on Oct 13, 2020

    @PaulWessel
    Contributor

    Branched merged so closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions