px.line erratic and wrong for large x value ranges
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 18.8k
- Forks
- 2.8k
- Merge medio
- 16 h 26 min
- PR fusionados (30 d)
- 21
Descripción
Problem
Plotting a straight line from ($-X$, 0) to ($+X$, 1) for various (large) $X$ within a much smaller window results in wrong and inconsistent behavior, as demonstrated in below minimum non-working examples (using a Jupyter notebook with plotly.js v2.27.0).
I doubt that this behavior can be explained by intrinsic rounding problems, since
>>> np.interp([-0.1,0.1],[-1e17,+1e17],[0,1])
array([0.5, 0.5])
>>> np.interp([-0.1,0.1],[-1e18,+1e18],[0,1])
array([0.5, 0.5])
Examples
Data frame
df = pd.DataFrame(dict(x=[-1e17,+1e17,-1e18,+1e18],
y=[0,1,0,1],
xlimit=['±1e17','±1e17','±1e18','±1e18']))
Very tight plotting range (symmetric 0.1)
fig = px.line(df,x='x',y='y',color='xlimit',
range_x=[-.1,.1],
range_y=[0.4,0.6],
width=400,
height=400,)
fig.update_traces(opacity=0.5)
fig.show()
Slightly wider plotting range (symmetric 0.3)
fig = px.line(df,x='x',y='y',color='xlimit',
range_x=[-.3,.3],
range_y=[0.4,0.6],
width=400,
height=400,)
fig.update_traces(opacity=0.5)
fig.show()
Another plotting range (symmetric 1)
fig = px.line(df,x='x',y='y',color='xlimit',
range_x=[-1,1],
range_y=[0.4,0.6],
width=400,
height=400,)
fig.update_traces(opacity=0.5)
fig.show()
Another even wider plotting range (symmetric 3)
fig = px.line(df,x='x',y='y',color='xlimit',
range_x=[-3,3],
range_y=[0.4,0.6],
width=400,
height=400,)
fig.update_traces(opacity=0.5)
fig.show()
Apparently wide enough plotting range (symmetric 3.2)
fig = px.line(df,x='x',y='y',color='xlimit',
range_x=[-3.2,3.2],
range_y=[0.4,0.6],
width=400,
height=400,)
fig.update_traces(opacity=0.5)
fig.show()
As far as my tests go, for any range_x that is wider than about ±3, the plotting is rendered correctly:
fig = px.line(df,x='x',y='y',color='xlimit',
range_x=[-1e17,1e17],
range_y=[0,1],
width=400,
height=400,)
fig.update_traces(opacity=0.5)
fig.show()
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el problema en un cuaderno de Jupyter usando px.line con el DataFrame proporcionado, valores de range_x reducidos y plotly.js v2.27.0. Compara las líneas renderizadas en los rangos de ejemplo y rastrea si el comportamiento se origina en la ruta de plotly.py px.line o en el renderizado de plotly.js; se considera terminado cuando las líneas de rangos grandes se renderizan de forma consistente en los casos proporcionados.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, jupyter-notebook, python
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100