Draping lines over a 3D plot

Hi, I have a questions about plotting lines (from a shapefile) over a 3D grid. This is related to this question and this question.
I have used grdsample to sample the elevation values onto the lines and plot them over the surface with plot3d, which is sortof working, as shown by the white lines in the below figure.

This issue is some of the white lines should be “behind” the coloured surface, and therefore not visible, but they are plotting ontop, as shown by the below portion of the figure.

image

Any idea how to fix this?

@andrebelem did you encounter this when create your Antarctic 3D figures?

Below is the code for plotting the white lines:

pygmt.grdtrack(
        grid = ice_surface_grid, 
        points = "path/to/shapefile",
        outfile="tmp.txt",
        skiprows=True,
)
fig.plot3d(
        data='tmp.txt', 
        pen="1p,white", 
        perspective=True,
        verbose='e',
        no_clip=False,
) 

Hi mdtanker.

You could try making a 2d georeferenciated image (like geotiff) of your map and them lay that image on top of the grid. I think it should work. Please let me know if it does because I want to do the same thing.

1 Like

Nice and interesting map Matt (@mdtanker).
When I plotted my 3D maps, I didn’t draw lines like that, but I believe the issue is that the plot3D is actually a projection “over” the rendering of the surface you have below. Have you tried slightly changing the perspective to see if it continues? I see that you are using a low angle. Perhaps with a slightly higher angle, it may improve, but I believe the problem will persist.

A practical and quick solution: Export the figure as SVG and edit the lines (it’s a quick option!). If that’s not possible, export it as JPG and use, for example, the resynthesizer in GIMP to erase the white line where it shouldn’t exist. It’s not the ideal solution, but it quickly resolves the issue if you need the image now.

I’ll do some experiments here with the 3D and get back to you.
Cheers

Yep. GMT has absolutely no knowledge of hidden line removal. It thus falls on the user to figure out a way to chop out only those pieces that should be seen and plot those with plot3.

I think no software can do it because it’s a matter of “plot over rendered surface”. But knowing that “before” (I mean, the azimuth and elevation), it’s possible to blank the undesired lines before plot3D.
@mdtanker, first you need to be sure your final perspective values, then you can advance cutting off the lines you don’t want to plot.