You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of expected behavior and the observed behavior
When plotting a Map using panels and Plotly extension, and the Scattermapbox function, dates data passed in the customdata attribute, and later used in the hovertemplate are not displayed correctly. Instead they are displayed as the seconds from 1970 representation. Plotting the Fig directly without wrapping it in a Plotly pane shows the expected behavior.
Complete, minimal, self-contained example code that reproduces the issue
importpandasaspdimportnumpyasnpimportplotly.graph_objectsasgoimportpanelaspn# Enable Panel extensionspn.extension('plotly')
# Create sample time series data with latitude and longitudenp.random.seed(42)
n_points=100data=pd.DataFrame({
'timestamp': pd.date_range(start='2023-01-01', periods=n_points, freq='T'),
'latitude': np.cumsum(np.random.randn(n_points) *0.01) +52.3702, # Centered around Amsterdam'longitude': np.cumsum(np.random.randn(n_points) *0.01) +4.8952, # Centered around Amsterdam
})
# Function to create a map using plotly.graph_objects and Scattermapboxdefcreate_map(data):
fig=go.Figure()
# Add the route using Scattermapboxfig.add_trace(go.Scattermapbox(
lat=data['latitude'],
lon=data['longitude'],
mode='markers+lines',
marker={'size': 10, 'color': 'blue'},
line={'width': 2, 'color': 'blue'},
hovertemplate=(
'<b>Timestamp</b>: %{customdata[0]}<br>'+'<b>Latitude</b>: %{lat:.5f}<br>'+'<b>Longitude</b>: %{lon:.5f}<extra></extra>'
),
customdata=data[['timestamp']], # Pass timestamp as custom data for hovertemplate
))
# Set the mapbox layoutfig.update_layout(
mapbox_style="open-street-map",
mapbox=dict(
center=go.layout.mapbox.Center(lat=52.3702, lon=4.8952),
zoom=12,
),
height=500,
margin={"r":0,"t":0,"l":0,"b":0}
)
returnfig# Create a Panel widget for interactive displaymap_plot=pn.pane.Plotly(create_map(data))
# Create a Panel layout for the dashboarddashboard=pn.Column(
pn.pane.Markdown("# Route Map Dashboard"),
map_plot
)
# Display the dashboarddashboard.show()
ALL software version info
Software Version Info
Description of expected behavior and the observed behavior
When plotting a Map using panels and Plotly extension, and the
Scattermapbox
function, dates data passed in thecustomdata
attribute, and later used in thehovertemplate
are not displayed correctly. Instead they are displayed as the seconds from 1970 representation. Plotting the Fig directly without wrapping it in a Plotly pane shows the expected behavior.Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output
No Stack traceback or errors messages are output.
Screenshots or screencasts of the bug in action
Wrong behavior
Expected behavior
The text was updated successfully, but these errors were encountered: