I’m plotting ‘markers+text’ in a scattergl() plot, and notice that the text is not collocated with the markers. It seems that scattergl() rounds the x-location for the text.
Here is the code with scattergl()
from datetime import datetime, timedelta
import numpy as np
import plotly.graph_objects as go
t = np.arange(datetime(2023,1,1,13,25,4), datetime(2023,1,1,13,37,4), timedelta(minutes=0.5)).astype(datetime)
y = np.arange(len(t))
txt = ['y={:d}'.format(x) for x in y]
fig_scattergl = go.Figure()
fig_scattergl.add_trace(go.Scattergl(x = t,
y = y,
mode = "markers+text",
text = txt,
textposition='middle right'))
fig_scattergl.update_layout(title='go.Scattergl()')
fig_scattergl.show()
fig_scattergl.write_html('fig_scattergl.html')
This creates:
Using scatter() works just fine:
fig_scatter = go.Figure()
fig_scatter.add_trace(go.Scatter(x = t,
y = y,
mode = "markers+text",
text = txt,
textposition='middle right'))
fig_scatter.update_layout(title='go.Scatter()')
fig_scatter.show()
fig_scatter.write_html('fig_scatter.html')
This creates:
I like using scattergl() for the obvious performance improvements. Any suggestion on how to fix this?