1

I am trying to add a point on a surface displayed with the function plot_trisurf. The point is present, but seems to be drawn before the surface, so that the only way to see it is to make the surface transparent. I would like this point to appear on the surface even if the surface is not transparent. Do you have any idea of how to do that ?

An example of the problem would be the following :

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt

Latitude = np.repeat(np.linspace(45.1525, 45.17, 1000), 15)
Longitude = np.array(list(np.linspace(5.9, 5.94, 1000))*15)
x = np.linspace(0,3,len(Latitude))
Altitude = np.sin(x)*np.cos(x**2)

fig = plt.figure(figsize=(15, 9))
ax = fig.gca(projection="3d")
ax.view_init(30, 250)
surf = ax.plot_trisurf(
    Latitude,
    Longitude,
    Altitude,
    cmap=plt.cm.jet,
    linewidth=0,
    alpha=0.2,
    edgecolor=None,
    antialiased=False,
)

s = ax.scatter(
    Latitude[10600],
    Longitude[10600],
    Altitude[10600],
    c="black",
    marker="*",
    s=100,
    depthshade=False,
)
plt.title((Latitude[10600], Longitude[10600], Altitude[10600]))
plt.show()

I also tried with scatter3D, and by increasing a little the altitude of the point with respect to the surface but nothing worked.

Thanks a lot for your help !

paugier
  • 1,838
  • 2
  • 20
  • 39
Claudine C
  • 11
  • 1
  • See https://stackoverflow.com/a/51243274/1779806. Your issue could be a duplicate of issue https://stackoverflow.com/q/51241367/1779806 ? – paugier Mar 03 '20 at 14:58
  • You should read that https://matplotlib.org/mpl_toolkits/mplot3d/faq.html#my-3d-plot-doesn-t-look-right-at-certain-viewing-angles – paugier Mar 03 '20 at 15:02
  • Thank you. I just tried this solution with pathpatch_2d_to_3d, but the problem stays the same. I think maybe it is because they use plot_surface while I am using plot_trisurf. I don't have and cannot create a 2D grid of latitude-longitude coordinate with my real dataset (the coordinates are aligned with a latitude nor a lontidude line), and so the plot_surface is not suitable for the present problem. – Claudine C Mar 04 '20 at 15:22

0 Answers0