get_computed_values() method to access computed axis ranges (#5552)#5570
Open
Khanz9664 wants to merge 4 commits intoplotly:mainfrom
Open
get_computed_values() method to access computed axis ranges (#5552)#5570Khanz9664 wants to merge 4 commits intoplotly:mainfrom
Khanz9664 wants to merge 4 commits intoplotly:mainfrom
Conversation
Implements an initial version of get_computed_values() as proposed in plotly#5552. Supports retrieval of computed axis ranges (axis_ranges) using a lightweight interface built on top of full_figure_for_development(). Includes input validation, safe layout traversal, JSON-serializable outputs, and unit tests for basic, multi-axis, and edge case scenarios.
…nt the new feature.
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.
Link to issue
#5552 - [FEATURE]: Access values calculated / derived by plotly.js as part of plotting
Closes #5552
Description of change
This PR introduces the initial implementation of get_computed_values() to expose computed values derived by Plotly.js.
Key aspects of this implementation:
Demo
import plotly.graph_objects as go
Create a sample figure
fig = go.Figure(go.Scatter(x=[1, 2, 3], y=[10, 20, 30]))
Retrieve computed values (e.g., autoranged axis limits)
computed = fig.get_computed_values(include=["axis_ranges"])
print(computed)
Output:
{'axis_ranges': {'xaxis': [...], 'yaxis': [...]}}
Testing strategy
Added a comprehensive test suite in tests/test_core/test_update_objects/test_get_computed_values.py:
Note: Tests use mocking for the Kaleido rendering engine to ensure environment-agnostic reliability during CI.
Additional information (optional)
This is a Phase 1 (MVP) implementation intended to establish the API structure. Future work can extend this method to support:
Guidelines