Tags: FBumann/xarray_plotly
Tags
Bump mkdocstrings[python] in the docs-dependencies group (#23) Bumps the docs-dependencies group with 1 update: [mkdocstrings[python]](https://github.com/mkdocstrings/mkdocstrings). Updates `mkdocstrings[python]` from 1.0.0 to 1.0.1 - [Release notes](https://github.com/mkdocstrings/mkdocstrings/releases) - [Changelog](https://github.com/mkdocstrings/mkdocstrings/blob/main/CHANGELOG.md) - [Commits](mkdocstrings/mkdocstrings@1.0.0...1.0.1) --- updated-dependencies: - dependency-name: mkdocstrings[python] dependency-version: 1.0.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: docs-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
feat: add _iter_all_traces helper and rewrite manipulation notebook (#18 ) * New helper at line 14: def _iter_all_traces(fig: go.Figure) -> Iterator: """Iterate over all traces in a figure, including animation frames. Yields traces from fig.data first, then from each frame in fig.frames. Useful for applying styling to all traces including those in animations. """ yield from fig.data for frame in fig.frames or []: yield from frame.data Refactored update_traces to use it (simpler now - removed the separate fig.update_traces() call): for trace in _iter_all_traces(fig): if selector is None: trace.update(**kwargs) else: if all(getattr(trace, k, None) == v for k, v in selector.items()): trace.update(**kwargs) The helper can now be reused internally wherever trace iteration including animation frames is needed. * Udpate notebook * Udpate notebook * Udpate notebook * Udpate notebook
feat: add figure combination utilities (overlay, add_secondary_y, upd… …ate_traces) (#16) * Files created/modified: ┌───────────────────────────────┬───────────────────────────────────────────────────────────────────────────────┐ │ File │ Changes │ ├───────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤ │ xarray_plotly/figures.py │ Renamed combine_figures → overlay_figures (with alias), added add_secondary_y │ ├───────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤ │ xarray_plotly/__init__.py │ Exported overlay_figures, add_secondary_y, combine_figures │ ├───────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤ │ tests/test_figures.py │ Added 16 new tests for add_secondary_y and alias verification (34 total) │ ├───────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤ │ docs/examples/combining.ipynb │ New notebook demonstrating both methods │ └───────────────────────────────┴───────────────────────────────────────────────────────────────────────────────┘ API: from xarray_plotly import overlay_figures, add_secondary_y # Overlay traces on same axes combined = overlay_figures(area_fig, line_fig) # Dual y-axis (different scales) combined = add_secondary_y(temp_fig, precip_fig, secondary_y_title="Rain (mm)") Features: - overlay_figures: Supports facets, animation, multiple overlays - add_secondary_y: Supports animation, custom y-axis title - Both create deep copies (originals not modified) - Both validate compatibility and raise clear errors Test results: 99 tests passing * Update notebook * Update notebook * 1. Added facet support to add_secondary_y - The function now creates secondary y-axes for each facet subplot (e.g., y→y4, y2→y5, y3→y6) 2. Updated tests - Added 6 new tests for faceted secondary y-axis: - test_matching_facets_works - test_facets_creates_multiple_secondary_axes - test_secondary_traces_remapped_to_correct_axes - test_mismatched_facets_raises - test_mismatched_facets_reversed_raises - test_facets_with_custom_title 3. Updated notebook (docs/examples/combining.ipynb): - Added new "With Facets" section showing add_secondary_y working with faceted figures - Changed "No Facet Support" limitation to "Mismatched Facet Structure" showing the error when structures don't match - Updated summary table: add_secondary_y now shows "Yes (must match)" for Facets 4. All 103 tests pass * Add notebook showing off manipulation options * Updated the notebook to: 1. Use overlay_figures for adding traces - shown under "Easy: Adding traces to faceted/animated figures" 2. Keep just two helpers: - update_animation_traces() - the main pain point - set_animation_speed() - for the deeply nested API 3. Added facets + animation example showing the helper works for both So the final picture is: ┌─────────────────────────────────────────────────────┬──────────────────────────────────────────┐ │ What you want to do │ Solution │ ├─────────────────────────────────────────────────────┼──────────────────────────────────────────┤ │ Add traces to animated/faceted figures │ overlay_figures() ✅ already in library │ ├─────────────────────────────────────────────────────┼──────────────────────────────────────────┤ │ Update trace style (line_width, etc.) on animations │ update_animation_traces() - needs helper │ ├─────────────────────────────────────────────────────┼──────────────────────────────────────────┤ │ Change animation speed │ set_animation_speed() - needs helper │ ├─────────────────────────────────────────────────────┼──────────────────────────────────────────┤ │ Everything else │ Works out of the box │ └─────────────────────────────────────────────────────┴──────────────────────────────────────────┘ Should we add update_animation_traces() and set_animation_speed() to xarray_plotly.figures as proper exported functions? They're simple but solve real pain points. * Final Public API from xarray_plotly import ( xpx, # Main entry point - accessor with IDE completion overlay, # Combine figures on same axes add_secondary_y, # Dual y-axis plots update_animation_traces, # Update traces in animation frames config, # Configuration settings ) Changes Summary ┌─────────────────────────┬──────────────────────────────────┐ │ Removed │ Reason │ ├─────────────────────────┼──────────────────────────────────┤ │ overlay_figures │ Renamed to overlay │ ├─────────────────────────┼──────────────────────────────────┤ │ combine_figures │ Alias removed │ ├─────────────────────────┼──────────────────────────────────┤ │ SLOT_ORDERS │ Implementation detail │ ├─────────────────────────┼──────────────────────────────────┤ │ DataArrayPlotlyAccessor │ Users use xpx() │ ├─────────────────────────┼──────────────────────────────────┤ │ DatasetPlotlyAccessor │ Users use xpx() │ ├─────────────────────────┼──────────────────────────────────┤ │ auto │ Rarely needed │ ├─────────────────────────┼──────────────────────────────────┤ │ set_animation_speed │ Kept as local helper in notebook │ └─────────────────────────┴──────────────────────────────────┘ ┌─────────────────────────┬─────────────────────────┐ │ Added │ Reason │ ├─────────────────────────┼─────────────────────────┤ │ update_animation_traces │ Was hidden, now exposed │ └─────────────────────────┴─────────────────────────┘ * Rename update_animation_traces to update_traces * Make module callable * Revert
1. xarray_plotly/plotting.py: Added robust parameter to imshow() wit… …h global bounds computation (#13) 2. xarray_plotly/accessor.py: Added robust parameter to accessor method 3. tests/test_accessor.py: Added 4 tests for bounds behavior New behavior: - Default: Global min/max across all data (fixes animation consistency) - robust=True: Uses 2nd/98th percentile (handles outliers) - zmin/zmax: User override still works
PreviousNext