px.line erratic and wrong for large x value ranges
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 18.8k
- Forks
- 2.8k
- Merge médio
- 16h 26min
- PRs com merge (30d)
- 21
Descrição
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()
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Reproduza o problema em um notebook Jupyter usando px.line com o DataFrame fornecido, valores de range_x estreitos e plotly.js v2.27.0. Compare as linhas renderizadas nos intervalos de exemplo e rastreie se o comportamento se origina no caminho de plotly.py px.line ou na renderização do plotly.js; considera-se concluído quando as linhas de intervalos amplos forem renderizadas de forma consistente nos casos fornecidos.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript, jupyter-notebook, python
- Domínio
- data-visualization
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100