Hello,
I’m having a strange issue where a graph_objects Figure with Scatergl is not drawing anything if there is an np.inf in the series, but only if the data is coming from a Pandas Dataframe. The below code shows an example of the issue (See 3rd figure).
import plotly.express as px
import plotly.graph_objects as go
import numpy as np
import pandas as pd
# Create a DataFrame with np.inf in a column
df = pd.DataFrame({
'x': [0, 1, 2, 3, 4],
'y': [0, 1, 4, 9, np.inf],
})
# Create a line plot (Things are OK)
fig = px.line(data_frame=df, x='x', y='y', title='Looks OK')
fig.show()
# Create a line plot w/ Scatter (Things are OK)
fig = go.Figure()
fig.add_trace(go.Scatter(
x=df['x'],
y=df['y'],
mode='lines',
))
fig.update_layout(title=dict(text="Looks OK"),)
fig.show()
# Create a line plot w/ Scattergl (Nothing shown on figure...)
fig = go.Figure()
fig.add_trace(go.Scattergl(
x=df['x'],
y=df['y'],
mode='lines',
))
fig.update_layout(title=dict(text="Nothing displayed..."),)
fig.show()
# Create a line plot w/ Scattergl (This is ok.... to_list fixes something?)
fig = go.Figure()
fig.add_trace(go.Scattergl(
x=df['x'].to_list(),
y=df['y'].to_list(),
mode='lines',
))
fig.update_layout(title=dict(text="Looks OK"),)
fig.show()