feat: Add Plotly as backend#378
Merged
AlejandroFernandezLuces merged 19 commits intomainfrom Oct 10, 2025
Merged
Conversation
Member
|
This looks really cool - I will try to review this tomorrow |
RobPasMue
requested changes
Oct 9, 2025
Member
RobPasMue
left a comment
There was a problem hiding this comment.
Looks pretty neat @AlejandroFernandezLuces -- I'd love to see more functionalities get added to it but as a starting point it's really good
Have we tried it with a library directly and see how it plays?
src/ansys/tools/visualization_interface/backends/plotly/plotly_interface.py
Outdated
Show resolved
Hide resolved
src/ansys/tools/visualization_interface/backends/plotly/plotly_interface.py
Outdated
Show resolved
Hide resolved
src/ansys/tools/visualization_interface/backends/plotly/plotly_interface.py
Show resolved
Hide resolved
RobPasMue
approved these changes
Oct 9, 2025
Member
RobPasMue
left a comment
There was a problem hiding this comment.
LGTM! Nice job @AlejandroFernandezLuces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Add Plotly as backend. I added a simple example to show how to use Plotly as a backend with the plotter. Minor changes to the BaseBackend class were needed, since I didn't realize some issues until the new backend was added.
Endless features can be added to this backend, so for the moment let's add the basics and we can check what we need to add in further iterations. For the moment, it allows to plot PyVista meshes, MeshObjectPlot objects and Plotly objects. Later we can add the button/picking features from the PyVista backend or even other features that plotly allows.
Layout object from Plotly is exposed through a property to allow uses to customize it as they want. As you can see in their docs, customization is pretty extensive: https://plotly.com/python-api-reference/generated/plotly.graph_objects.Layout.html
Also, I had to implement a simple image comparison for testing Plotly plot outputs, which seems to be working fine from what I see in the image cache.
pytest-pyvistais not compatible with Plotly.Example
This is what the included example looks like:
Recording.2025-10-08.164706.mp4