Skip to content

Conversation

@FBumann
Copy link
Member

@FBumann FBumann commented Oct 18, 2025

Description

Improve handling of pie plots with scenarios and periods

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactoring

Related Issues

Closes #(issue number)

Testing

  • I have tested my changes
  • Existing tests still pass

Checklist

  • My code follows the project style
  • I have updated documentation if needed
  • I have added tests for new functionality (if applicable)

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 18, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/398-feature-facet-plots-in-results-pie

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…e/398-feature-facet-plots-in-results-pie

# Conflicts:
#	flixopt/results.py
@FBumann FBumann merged commit b94f223 into feature/plots-with-faceting-and-animations Oct 18, 2025
4 of 8 checks passed
@FBumann FBumann deleted the feature/398-feature-facet-plots-in-results-pie branch October 18, 2025 17:31
FBumann added a commit that referenced this pull request Oct 19, 2025
* Feature/398 feature facet plots in results (#419)

* Add animation and faceting options to plots

* Adjust size of the frame

* Utilize plotly express directly

* Rmeocve old class

* Use plotly express and modify stackgroup afterwards

* Add modifications also to animations

* Mkae more compact

* Remove height stuff

* Remove line and make set opacity =0 for area

* Integrate faceting and animating into existing with_plotly method

* Improve results.py

* Improve results.py

* Move check if dims are found to plotting.py

* Fix usage of indexer

* Change selection string with indexer

* Change behaviout of parameter "indexing"

* Update CHANGELOG.md

* Add new selection parameter to plotting methods

* deprectae old indexer parameter

* deprectae old indexer parameter

* Add test

* Add test

* Add test

* Add test

* Fix not supportet check for matplotlib

* Typo in CHANGELOG.md

* Feature/398 feature facet plots in results heatmaps (#418)

* Add animation and faceting options to plots

* Adjust size of the frame

* Utilize plotly express directly

* Rmeocve old class

* Use plotly express and modify stackgroup afterwards

* Add modifications also to animations

* Mkae more compact

* Remove height stuff

* Remove line and make set opacity =0 for area

* Integrate faceting and animating into existing with_plotly method

* Improve results.py

* Improve results.py

* Move check if dims are found to plotting.py

* Fix usage of indexer

* Change selection string with indexer

* Change behaviout of parameter "indexing"

* Update CHANGELOG.md

* Add new selection parameter to plotting methods

* deprectae old indexer parameter

* deprectae old indexer parameter

* Add test

* Add test

* Add test

* Add test

* Add heatmap support

* Unify to a single heatmap method per engine

* Change defaults

* readd time reshaping

* readd time reshaping

* lengthen scenario example

* Update

* Improve heatmap plotting

* Improve heatmap plotting

* Moved reshaping to plotting.py

* COmbinations are possible!

* Improve 'auto'behavioour

* Improve 'auto' behavioour

* Improve 'auto' behavioour

* Allow multiple variables in a heatmap

* Update modeule level plot_heatmap()

* remove code duplication

* Allow Dataset instead of List of DataArrays

* Allow Dataset instead of List of DataArrays

* Update plot tests

* FIx Missing renme in ElementResults.plot_heatmap()

* Update API

* Feature/398 feature facet plots in results charge state (#417)

* Add animation and faceting options to plots

* Adjust size of the frame

* Utilize plotly express directly

* Rmeocve old class

* Use plotly express and modify stackgroup afterwards

* Add modifications also to animations

* Mkae more compact

* Remove height stuff

* Remove line and make set opacity =0 for area

* Integrate faceting and animating into existing with_plotly method

* Improve results.py

* Improve results.py

* Move check if dims are found to plotting.py

* Fix usage of indexer

* Change selection string with indexer

* Change behaviout of parameter "indexing"

* Update CHANGELOG.md

* Add new selection parameter to plotting methods

* deprectae old indexer parameter

* deprectae old indexer parameter

* Add test

* Add test

* Add test

* Add test

* Add heatmap support

* Unify to a single heatmap method per engine

* Change defaults

* readd time reshaping

* readd time reshaping

* lengthen scenario example

* Update

* Improve heatmap plotting

* Improve heatmap plotting

* Moved reshaping to plotting.py

* COmbinations are possible!

* Improve 'auto'behavioour

* Improve 'auto' behavioour

* Improve 'auto' behavioour

* Allow multiple variables in a heatmap

* Update modeule level plot_heatmap()

* remove code duplication

* Allow Dataset instead of List of DataArrays

* Allow Dataset instead of List of DataArrays

* Add tests

* More examples

* Update plot_charge state()

* Try 1

* Try 2

* Add more examples

* Add more examples

* Add smooth line for charge state and use "area" as default

* Update scenario_example.py

* Update tests

* Fix Error handling in plot_heatmap()

* Feature/398 feature facet plots in results pie (#421)

* Add animation and faceting options to plots

* Adjust size of the frame

* Utilize plotly express directly

* Rmeocve old class

* Use plotly express and modify stackgroup afterwards

* Add modifications also to animations

* Mkae more compact

* Remove height stuff

* Remove line and make set opacity =0 for area

* Integrate faceting and animating into existing with_plotly method

* Improve results.py

* Improve results.py

* Move check if dims are found to plotting.py

* Fix usage of indexer

* Change selection string with indexer

* Change behaviout of parameter "indexing"

* Update CHANGELOG.md

* Add new selection parameter to plotting methods

* deprectae old indexer parameter

* deprectae old indexer parameter

* Add test

* Add test

* Add test

* Add test

* Add heatmap support

* Unify to a single heatmap method per engine

* Change defaults

* readd time reshaping

* readd time reshaping

* lengthen scenario example

* Update

* Improve heatmap plotting

* Improve heatmap plotting

* Moved reshaping to plotting.py

* COmbinations are possible!

* Improve 'auto'behavioour

* Improve 'auto' behavioour

* Improve 'auto' behavioour

* Allow multiple variables in a heatmap

* Update modeule level plot_heatmap()

* remove code duplication

* Allow Dataset instead of List of DataArrays

* Allow Dataset instead of List of DataArrays

* Add tests

* More examples

* Update plot_charge state()

* Try 1

* Try 2

* Add more examples

* Add more examples

* Add smooth line for charge state and use "area" as default

* Update scenario_example.py

* Update tests

* Handle extra dims in pie plots by selecting the first

* 6. Optimized time-step check

  - Replaced pandas Series diff() with NumPy np.diff() for better performance
  - Changed check from > 0 to > 1 (can't calculate diff with 0 or 1 element)
  - Converted to seconds first, then to minutes to avoid pandas timedelta conversion issues

* Typo

* Improve type handling

* Update other tests

* Handle backwards compatability

* Add better error messages if both new and old api are used

* Add old api explicitly

* Add old api explicitly

* Improve consistency and properly deprectae the indexer parameter

* Remove amount of new tests

* Remove amount of new tests

* Fix CONTRIBUTING.md

* Remove old test file

* Add tests/test_heatmap_reshape.py

* Add tests/test_heatmap_reshape.py

* Remove unused method

* - Implemented dashed line styling for "mixed" variables (variables with both positive and negative values)
  - Only stack "positive" and "negative" classifications, not "mixed" or "zero"

* - Added fill parameter to module-level plot_heatmap function (line 1914)
  - Added fill parameter to CalculationResults.plot_heatmap method (line 702)
  - Forwarded fill parameter to both heatmap_with_plotly and heatmap_with_matplotlib functions

* - Added np.random.seed(42) for reproducible test results
  - Added specific size assertions to all tests:
    - Daily/hourly pattern: 3 days × 24 hours
    - Weekly/daily pattern: 1 week × 7 days
    - Irregular data: 25 hours × 60 minutes
    - Multidimensional: 2 days × 24 hours with preserved scenario dimension

* Improve Error Message if too many dims for matplotlib

* Improve Error Message if too many dims for matplotlib

* Improve Error Message if too many dims for matplotlib

* Rename _apply_indexer_to_data() to _apply_selection_to_data()

* Bugfix

* Update CHANGELOG.md

* Catch edge case in with_plotly()

* Add strict=True

* Improve scenario_example.py

* Improve scenario_example.py

* Change logging level in essage about time reshape

* Update CHANGELOG.md
FBumann added a commit that referenced this pull request Oct 24, 2025
* Feature/398 feature facet plots in results (#419)

* Add animation and faceting options to plots

* Adjust size of the frame

* Utilize plotly express directly

* Rmeocve old class

* Use plotly express and modify stackgroup afterwards

* Add modifications also to animations

* Mkae more compact

* Remove height stuff

* Remove line and make set opacity =0 for area

* Integrate faceting and animating into existing with_plotly method

* Improve results.py

* Improve results.py

* Move check if dims are found to plotting.py

* Fix usage of indexer

* Change selection string with indexer

* Change behaviout of parameter "indexing"

* Update CHANGELOG.md

* Add new selection parameter to plotting methods

* deprectae old indexer parameter

* deprectae old indexer parameter

* Add test

* Add test

* Add test

* Add test

* Fix not supportet check for matplotlib

* Typo in CHANGELOG.md

* Feature/398 feature facet plots in results heatmaps (#418)

* Add animation and faceting options to plots

* Adjust size of the frame

* Utilize plotly express directly

* Rmeocve old class

* Use plotly express and modify stackgroup afterwards

* Add modifications also to animations

* Mkae more compact

* Remove height stuff

* Remove line and make set opacity =0 for area

* Integrate faceting and animating into existing with_plotly method

* Improve results.py

* Improve results.py

* Move check if dims are found to plotting.py

* Fix usage of indexer

* Change selection string with indexer

* Change behaviout of parameter "indexing"

* Update CHANGELOG.md

* Add new selection parameter to plotting methods

* deprectae old indexer parameter

* deprectae old indexer parameter

* Add test

* Add test

* Add test

* Add test

* Add heatmap support

* Unify to a single heatmap method per engine

* Change defaults

* readd time reshaping

* readd time reshaping

* lengthen scenario example

* Update

* Improve heatmap plotting

* Improve heatmap plotting

* Moved reshaping to plotting.py

* COmbinations are possible!

* Improve 'auto'behavioour

* Improve 'auto' behavioour

* Improve 'auto' behavioour

* Allow multiple variables in a heatmap

* Update modeule level plot_heatmap()

* remove code duplication

* Allow Dataset instead of List of DataArrays

* Allow Dataset instead of List of DataArrays

* Update plot tests

* FIx Missing renme in ElementResults.plot_heatmap()

* Update API

* Feature/398 feature facet plots in results charge state (#417)

* Add animation and faceting options to plots

* Adjust size of the frame

* Utilize plotly express directly

* Rmeocve old class

* Use plotly express and modify stackgroup afterwards

* Add modifications also to animations

* Mkae more compact

* Remove height stuff

* Remove line and make set opacity =0 for area

* Integrate faceting and animating into existing with_plotly method

* Improve results.py

* Improve results.py

* Move check if dims are found to plotting.py

* Fix usage of indexer

* Change selection string with indexer

* Change behaviout of parameter "indexing"

* Update CHANGELOG.md

* Add new selection parameter to plotting methods

* deprectae old indexer parameter

* deprectae old indexer parameter

* Add test

* Add test

* Add test

* Add test

* Add heatmap support

* Unify to a single heatmap method per engine

* Change defaults

* readd time reshaping

* readd time reshaping

* lengthen scenario example

* Update

* Improve heatmap plotting

* Improve heatmap plotting

* Moved reshaping to plotting.py

* COmbinations are possible!

* Improve 'auto'behavioour

* Improve 'auto' behavioour

* Improve 'auto' behavioour

* Allow multiple variables in a heatmap

* Update modeule level plot_heatmap()

* remove code duplication

* Allow Dataset instead of List of DataArrays

* Allow Dataset instead of List of DataArrays

* Add tests

* More examples

* Update plot_charge state()

* Try 1

* Try 2

* Add more examples

* Add more examples

* Add smooth line for charge state and use "area" as default

* Update scenario_example.py

* Update tests

* Fix Error handling in plot_heatmap()

* Feature/398 feature facet plots in results pie (#421)

* Add animation and faceting options to plots

* Adjust size of the frame

* Utilize plotly express directly

* Rmeocve old class

* Use plotly express and modify stackgroup afterwards

* Add modifications also to animations

* Mkae more compact

* Remove height stuff

* Remove line and make set opacity =0 for area

* Integrate faceting and animating into existing with_plotly method

* Improve results.py

* Improve results.py

* Move check if dims are found to plotting.py

* Fix usage of indexer

* Change selection string with indexer

* Change behaviout of parameter "indexing"

* Update CHANGELOG.md

* Add new selection parameter to plotting methods

* deprectae old indexer parameter

* deprectae old indexer parameter

* Add test

* Add test

* Add test

* Add test

* Add heatmap support

* Unify to a single heatmap method per engine

* Change defaults

* readd time reshaping

* readd time reshaping

* lengthen scenario example

* Update

* Improve heatmap plotting

* Improve heatmap plotting

* Moved reshaping to plotting.py

* COmbinations are possible!

* Improve 'auto'behavioour

* Improve 'auto' behavioour

* Improve 'auto' behavioour

* Allow multiple variables in a heatmap

* Update modeule level plot_heatmap()

* remove code duplication

* Allow Dataset instead of List of DataArrays

* Allow Dataset instead of List of DataArrays

* Add tests

* More examples

* Update plot_charge state()

* Try 1

* Try 2

* Add more examples

* Add more examples

* Add smooth line for charge state and use "area" as default

* Update scenario_example.py

* Update tests

* Handle extra dims in pie plots by selecting the first

* 6. Optimized time-step check

  - Replaced pandas Series diff() with NumPy np.diff() for better performance
  - Changed check from > 0 to > 1 (can't calculate diff with 0 or 1 element)
  - Converted to seconds first, then to minutes to avoid pandas timedelta conversion issues

* Typo

* Improve type handling

* Update other tests

* Handle backwards compatability

* Add better error messages if both new and old api are used

* Add old api explicitly

* Add old api explicitly

* Improve consistency and properly deprectae the indexer parameter

* Remove amount of new tests

* Remove amount of new tests

* Fix CONTRIBUTING.md

* Remove old test file

* Add tests/test_heatmap_reshape.py

* Add tests/test_heatmap_reshape.py

* Remove unused method

* - Implemented dashed line styling for "mixed" variables (variables with both positive and negative values)
  - Only stack "positive" and "negative" classifications, not "mixed" or "zero"

* - Added fill parameter to module-level plot_heatmap function (line 1914)
  - Added fill parameter to CalculationResults.plot_heatmap method (line 702)
  - Forwarded fill parameter to both heatmap_with_plotly and heatmap_with_matplotlib functions

* - Added np.random.seed(42) for reproducible test results
  - Added specific size assertions to all tests:
    - Daily/hourly pattern: 3 days × 24 hours
    - Weekly/daily pattern: 1 week × 7 days
    - Irregular data: 25 hours × 60 minutes
    - Multidimensional: 2 days × 24 hours with preserved scenario dimension

* Improve Error Message if too many dims for matplotlib

* Improve Error Message if too many dims for matplotlib

* Improve Error Message if too many dims for matplotlib

* Rename _apply_indexer_to_data() to _apply_selection_to_data()

* Bugfix

* Update CHANGELOG.md

* Catch edge case in with_plotly()

* Add strict=True

* Improve scenario_example.py

* Improve scenario_example.py

* Change logging level in essage about time reshape

* Update CHANGELOG.md

* Add XarrayColorMapper

* Add XarrayColorMapper to CalculationResults

* Renamed variable

* Add test file

* Improve integration of the ColorMapper

* Improve integration of the ColorMapper

* Update resolve_colors and move to plotting.py

* Temporalily add example script to show/document intended usage

* Add method create_color_mapper

* Improve docstring

* Remove example file again

* Update CHANGELOG.md

* Add create_color_mapper to SegmentedResults

* Add create_color_mapper to complex_example

* Missed some renames

* Fix warning in plot_charge_state()

* Allow for discrete color assignments with rules

* Remove some half baked validation

* Add more color families

* Use 1:7 colors for more distinct colors

* Add color mapper to complex example

* Update CHANGELOG.md

* Convert numpy style docstrings to google style

* Use re.search instead of re.match

* Update tests

* Applying ordering to Dataset as well

* This approach:
  - Prevents silent data loss when values like 1, 1.0, and "1" collide
  - Provides actionable error messages showing exactly which values are problematic
  - Allows users to fix their data rather than hiding the issue

* Improve Error Message

* Enable sorting fpr Datasets

* completed the integration of XarrayColorMapper into both with_plotly and with_matplotlib

* simplified with_matplotlib significantly

* Update plotting methods to focus on xr.DataArray only

* Remove duplication

* Remove duplication

* Make check faster

* Make check faster

* Make check faster

* Fixx plotting issues

* Switch back to Dataset first

* Remove redundant code

* XarrayColorMapper is now Dataset-only!

* Update tests accordingly

* Fix issue in aggregation.py with new plotting

* Fix issue plotting in examples (using dataframes)

* Fix issue plotting in examples (using dataframes)

* Fix issue plotting scalar Datasets

* Improve labeling of plots

* Improve handling of time reshape in plots

* Update usage of plotting methods

* Update pie plots to use Dataset instead of DataFrame

* Makde charge state line in plots black always

* Improve examples

* Make plotting methods much more flexible

* Add test

* Add plotting kwargs to plotting functions

* add imshow kwargs

* Fix nans in plots

* Replace XarrayColorMapper with ComponentColorManager

* Add repr and str method

* Added tests

* Add caching to ColorManager

* Test caching

* Change default colormap and improve colormap settings

* Automatically initiallize the ColorManager

* Use Dark24 as the default colormap

* Rename auto_group_components() to apply_colors()

* Use ColorManager in examples

* Fix tests

* Extend config to cover plotting settings

* Centralize behaviour

* More config options

* More config options

* More config options

* Rename config parameter

* Improve color defaults

* Removed 'auto' and Simplified Color Resolution

* Fix ColorProcessor to accept qualitative colorscales

* Fix ColorProcessor to accept qualitative colorscales

* Remove old test

* Simplified tests

* Update examples and CHANGELOG.md

* Update method name

* Update examples

* extended ComponentColorManager to support flow-level color distinctio

* Change default flow shading

* Improve Setup_colors

* Use external dependency for color handling

* Make colour dependency optional

* streamlined the ColorManager configuration API

* streamlined the ColorManager configuration API

* Update usages of new api

* Update CHANGELOG.md

* Update examples

* use turbo as the new default sequential colormap

* Add support for direct mappings of components

* Add support for direct mappings of components

* Add configurable flow_variation

* Update tests

* Make color getter mroe robust

* Make color getter mroe robust

* Temp

* Update default colormap

* Update default colormap to default colorscale

* Update default Improve colorscale handling

* Update default color families

* Update plotly template

* Update example

* Simplify test

* Update color family defaults

* Simplify documentation

* Typo

* Make matplotlib backend switch more robst

* Update setup_colors() in SegmentedCalculationResults

* Fix example

* Update CHANGELOG.md

* Simplify export_figure()

* Update Examples and CHANGELOG.md

* Simplified Config

* Simplified Colormanagement

* Simplified Colormanagement

* Simplified Colormanagement

* Add element name itself to color dict

* Fix examples

* Bugfix

* Bugfix

* Remove coloring related stuff

* Reverse color and CONFIG related changes in plotting.py

* Reverse color and CONFIG related changes in plotting.py

* Reverse color and CONFIG related changes in plotting.py

* Reverse color and CONFIG related changes in plotting.py

* Reverse color and CONFIG related changes in plotting.py

* Update CHANGELOG.md

* Update CHANGELOG.md

* Remove duplicate resolve color calls

* Improve pie plot

* Simplify pie plot

* Simplify pie plot

* Bugfix

* Bugfix

* Bugfix

* Bugfix

* Bugfix

* Add Series Support for plotting

* Simplify pie plots to be Series First to remove unnessesary data transformations

* Update Typehints

* Test datatypes

* Test datatypes and plotting modes

* Test datatypes and plotting modes

* Test datatypes and plotting modes

* Test datatypes and plotting modes

* Update CHANGELOG.md

* Potential Bugfix

* Fix: plotly kwargs usage

* Update docstrings and fix usage of kwargs

* Improve error handling

* Remove trace and layout kwargs

* Prevent potential bugs in plotting.py

* Improve tests
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.

2 participants