plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

generate deterministic IDs for SVG elements to facilitate diff

Open gvwilson opened this issue 6 years ago • 8 comments

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

gvwilson avatar Dec 04 '19 16:12 gvwilson

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

nicolaskruchten avatar Dec 04 '19 16:12 nicolaskruchten

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

emmanuelle avatar Dec 04 '19 16:12 emmanuelle

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 avatar Dec 04 '19 16:12 gvwilson

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

gvwilson avatar Dec 04 '19 16:12 gvwilson

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

emmanuelle avatar Dec 04 '19 16:12 emmanuelle

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

gvwilson avatar Dec 04 '19 16:12 gvwilson

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?).

antoinerg avatar Dec 04 '19 20:12 antoinerg

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

etpinard avatar Dec 04 '19 22:12 etpinard