Skip to content

docs: Add unsafe_update_figure doc#1058

Merged
jnumainville merged 6 commits intodeephaven:mainfrom
jnumainville:docs_push_unsafe_update_figure
Jan 13, 2025
Merged

docs: Add unsafe_update_figure doc#1058
jnumainville merged 6 commits intodeephaven:mainfrom
jnumainville:docs_push_unsafe_update_figure

Conversation

@jnumainville
Copy link
Copy Markdown
Collaborator

Adds an unsafe_update_figure doc with some usages that I have been asked for or otherwise seen.

@jnumainville jnumainville marked this pull request as ready for review December 9, 2024 20:52
@jnumainville jnumainville requested a review from dsmmcken December 9, 2024 20:52
> [!WARNING]
> `dx` maps `Table` columns to an index of a trace within `Figure.data` which will break if the trace order changes. Do not remove traces. Add new traces at the end of the list.

`unsafe_update_figure` accepts a function that takes a Plotly `Figure` object as input and optionally returns a modified `Figure` object. If a figure is not returned, it is assumed that the input figure has been modified in place.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should link to full plotly.js docs where they can see figure docs

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, linked on the first instance

A Plotly [`Figure`](https://plotly.com/python/figure-structure/) object backs every `dx` chart, and `unsafe_update_figure` allows you to directly modify this object.

> [!WARNING]
> `dx` maps `Table` columns to an index of a trace within `Figure.data` which will break if the trace order changes. Do not remove traces. Add new traces at the end of the list.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would directly state why it is labelled "unsafe" at the start of this warning.

Update figure is marked "unsafe" because some modifications can entirely break your figure, and care must be taken to not ...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Contributor

@bmingles bmingles Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to explicitly call out the relationship of unsafe_update_figure to the plotly docs. I found it very confusing searching for update_figure in the plotly docs since I wrongfully assumed unsafe_update_figure was a wrapper for something with a similar name. I found the figure reference doc (https://plotly.com/python/reference/) to be a little more helpful in helping me find what I was looking for. It has more direct figure.update_xxx examples throughout.

I left a suggested change above.

Comment thread plugins/plotly-express/docs/unsafe-update-figure.md Outdated
Copy link
Copy Markdown
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jnumainville
Copy link
Copy Markdown
Collaborator Author

@dsmmcken any further comments?

@jnumainville jnumainville merged commit 90c8e19 into deephaven:main Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants