plotly / plotly.py

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

generate deterministic IDs for SVG elements to facilitate diff #1968

Open gvwilson opened 4 years ago

gvwilson commented 4 years ago

When saving figure as SVG using write_image, Plotly Express generates random unique IDs for elements. As a result, git diff thinks re-generated figures have changed even when they haven't (see screenshot). If the IDs were generated in some deterministic way depending solely on figure contents, so that they only changed when the figure itself had visually changed, git would be a lot happier. Screen Shot 2019-12-04 at 11 14 33 AM

see #3393

nicolaskruchten commented 4 years ago

Thanks for creating this issue! This is something we've discussed internally with no real resolution so far... Plotly.py delegates to https://github.com/plotly/orca for SVG-generation, so we would need an Orca flag to modulate this behaviour or at least fix the random seed that it uses or something.

Heads-up @antoinerg :)

emmanuelle commented 4 years ago

Great to see you here @gvwilson ! ;-) Would love to know more about how you're using plotly.py one of these days!

gvwilson commented 4 years ago

Thanks - I'm regenerating a lot of figures for lessons using command-line scripts and getting a linearly-increasing number of spurious diffs because of this.

gvwilson commented 4 years ago

@emmanuelle I'm trying to re-learn some basic statistics, mostly out of shame :-)

emmanuelle commented 4 years ago

Well at least it's RE-learning for you :-).

gvwilson commented 4 years ago

You'd be amazed how much math someone can forget in (checks) 37 years.

antoinerg commented 4 years ago

I agree that generating deterministic IDs should absolutely be a feature. If it requires work on Orca, I would gladly undertake it myself. However, I think it might be better to implement this directly in plotly.js. If I'm not mistaken, there might already an issue for this in https://github.com/plotly/plotly.js but I can't seem to find it at the moment (@etpinard can you point me to it?).

etpinard commented 4 years ago

Here -> https://github.com/plotly/orca/issues/133