Scatter lat, lon, altitude (3d scatter) on mapbox


I try to plot an aircraft route overlaying an open street map, i.e. I have Latitude, Longitude and altitude and would like to do a 3d scatter on top of the mapping object in python.

I have searched for a simple solution but cannot find one. Any advice?

Here is a simple, non-working example.

import plotly.graph_objects as go

lon = [15.3, 15.35, 15.4]
lat = [58.3, 60.7, 64.2]
altitude = [1000, 2000, 3000]  # How do I pass this information to the scatterplot??
fig = go.Figure(go.Scattermapbox(
    marker={'size': 10},

   margin={'l': 0, 't': 0, 'b': 0, 'r': 0},
       'style': "open-street-map",
       'center_lat': lat[0],
       'center_lon': lon[0],
       'zoom': 6

Hi @marba751

Just as an Idea consider this comment: you can use scatter3D to plot your points or lines, the put the scattermapbox as background of the plot.

Hi @Bijan ,

Thank you for the response. I tried adding scatter3D, however it creates a new axis on top of the mapbox, thus not a working solution. Do you know if there is a way to override this?

Dear @marba751

Unfortunately I just saw that someone did what I suggested and I don’t know how to do this.


I also saw the following plot to air routes in Plotly examples and thought maybe become useful for you.

import plotly.graph_objects as go
import pandas as pd

df_airports = pd.read_csv('')

df_flight_paths = pd.read_csv('')

fig = go.Figure()

    locationmode = 'USA-states',
    lon = df_airports['long'],
    lat = df_airports['lat'],
    hoverinfo = 'text',
    text = df_airports['airport'],
    mode = 'markers',
    marker = dict(
        size = 2,
        color = 'rgb(255, 0, 0)',
        line = dict(
            width = 3,
            color = 'rgba(68, 68, 68, 0)'

flight_paths = []
for i in range(len(df_flight_paths)):
            locationmode = 'USA-states',
            lon = [df_flight_paths['start_lon'][i], df_flight_paths['end_lon'][i]],
            lat = [df_flight_paths['start_lat'][i], df_flight_paths['end_lat'][i]],
            mode = 'lines',
            line = dict(width = 1,color = 'red'),
            opacity = float(df_flight_paths['cnt'][i]) / float(df_flight_paths['cnt'].max()),

    title_text = 'Feb. 2011 American Airline flight paths<br>(Hover for airport names)',
    showlegend = False,
    geo = dict(
        scope = 'north america',
        projection_type = 'azimuthal equal area',
        showland = True,
        landcolor = 'rgb(243, 243, 243)',
        countrycolor = 'rgb(204, 204, 204)',

@marba751 This old plot can suggest how you can create a 3d scatter over a map.
As I can remember, the data for France map have been extracted from a geojson file. The map is drawn on the plane z=0. On xaxis is longitude and on yaxis the latitude of points on the lines retrieved from the geojson file , i.e. you should define:

fig=go.Figure(go.Scatter3d(x=lons, y=lats, z=z, mode.....)
1 Like