plotly / plotly/plotly.py

px.line erratic and wrong for large x value ranges

Abierto
#4,655 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug P3
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()

pxLine_0_1

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()

pxLine_0_3

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()

pxLine_1

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()

pxLine_3

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()

pxLine_3_2

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()

px_Line_full

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. 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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.