plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.25k stars 2.55k forks source link

ODE integrator for FF streamline produces NaNs #1451

Open kel85uk opened 5 years ago

kel85uk commented 5 years ago

While providing a current field to a FF streamline object, I get this error. This error happens even in current plotly version: e53e626d59495d440341751f60aeff73ff365c28 (The last commit I tested the workflow in)

image

The same field when provided to a matplotlib streamplot object produces the expected lines: image

The only difference which I could see is the ODE integrator being used in matplotlib and plotly. I refer to https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/streamplot.py with matplotlib using Heun's method.

jonmmease commented 5 years ago

Hi @kel85uk, could you add a minimal reproducible example that works in matplotlib but not in plotly? Thanks!

kel85uk commented 5 years ago

Hi @jonmmease, thanks for the response. I have added an example notebook and the accompanying dataset. Any help in this would be much appreciated.

minimum_reproducible_example.zip

kel85uk commented 5 years ago

Hi @jonmmease, I was wondering if there's any update on the issue?

jonmmease commented 5 years ago

Hi @kel85uk, no I don't think anyone has looked at it yet. We're definitely open to help if anyone would like to take a look at https://github.com/plotly/plotly.py/blob/master/plotly/figure_factory/_streamline.py and try to track down the issue.

Shellloman commented 2 years ago

hi @jonmmease, i have the same issue than @kel85uk so i decided to look further in _streamline.py. It's appear that the issue come from line 207 and 213 where self.value_at return 0. So dt_ds variable is infinite then f and g function return nan.

The best 'quick fix' i found is replacing 'except IndexError:' line 238 by 'except (IndexError, ValueError):'. I know is not the best way to fix the issue, but it's the only one i found working well. (the interesting side effect is that create_streamline handle now the nan value in u and v)

I hope you could add some fix in the next release.

ps : i used the same dataset than @kel85uk

Shellloman commented 2 years ago

hi @emmanuelle, have you seen my previous message ? Could you tell me if an update is considered ?