Skip to content

Added plot style context managers to all plot methods#208

Merged
jamesramsden-bh merged 16 commits intodevelopfrom
Python_Toolkit-#204-PlotStyleContext
Mar 19, 2026
Merged

Added plot style context managers to all plot methods#208
jamesramsden-bh merged 16 commits intodevelopfrom
Python_Toolkit-#204-PlotStyleContext

Conversation

@Tom-Kingstone
Copy link
Contributor

@Tom-Kingstone Tom-Kingstone commented Mar 12, 2026

NOTE: Depends on

Issues addressed by this PR

Closes #204
Closes #207

This removes the need to globally set plot style in dependent packages (see this PR for example), and allows setting it dynamically on method call using the kwarg "style_context". By default all the plot methods will use "python_toolkit.bhom" as the plot style, but this can be overridden by passing "default" to instead use whatever default matplotlib has currently set.

Moved the mplstyle files to the root of the package just to allow easy selection in code (allows passing "python_toolkit.bhom" instead of the path to the .mplstyle file)

Also added a dark theme (much to the benefit of my eyes on dark backgrounds) called bhom_dark.

This only works for matplotlib based plots, so plotly plots (like parallel_coordinate_plot) do not allow this.

Also @Felix-Mallinder bug fixes from #207

Test files

Run the unit tests and ensure they pass, see it in action by using any of the matplotlib based plot methods (eg. heatmap) and passing style_context="python_toolkit.bhom" to the method.

Changelog

  • Added more flexible style selection through the style_context kwarg for all matplotlib plot methods
  • Added bhom_dark matplotlib style sheet.

Additional comments

packages that depend on python_toolkit must change any references to the python_toolkit/bhom/bhom.mplstyle file to python_toolkit/bhom.mplstyle or more cleanly with matplotlib, use "python_toolkit.bhom"

@Tom-Kingstone Tom-Kingstone self-assigned this Mar 12, 2026
@Tom-Kingstone Tom-Kingstone added the type:feature New capability or enhancement label Mar 12, 2026
@Tom-Kingstone Tom-Kingstone force-pushed the Python_Toolkit-#204-PlotStyleContext branch from 6ab9999 to c387559 Compare March 12, 2026 13:19
@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check installer

@bhombot-ci
Copy link

bhombot-ci bot commented Mar 16, 2026

@Tom-Kingstone to confirm, the following actions are now queued:

  • check installer

@bhombot-ci
Copy link

bhombot-ci bot commented Mar 17, 2026

@Tom-Kingstone just to let you know, I have provided a check-installer result to this Pull Request as it was detected to be linked to other Pull Requests in a series. The comment which triggered this check came from @Tom-Kingstone on LadybugTools_Toolkit

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check core
@BHoMBot check compliance

@bhombot-ci
Copy link

bhombot-ci bot commented Mar 18, 2026

@Tom-Kingstone to confirm, the following actions are now queued:

  • check core
  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check branch-compliance
  • check dataset-compliance
  • check copyright-compliance

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check null-handling
@BHoMBot check serialisation
@BHoMBot check versioning

@bhombot-ci
Copy link

bhombot-ci bot commented Mar 18, 2026

@Tom-Kingstone to confirm, the following actions are now queued:

  • check null-handling
  • check serialisation
  • check versioning

Copy link
Contributor

@jamesramsden-bh jamesramsden-bh left a comment

Choose a reason for hiding this comment

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

Have tested with run_tests.bat and a manual spot check, happy to merge

@jamesramsden-bh
Copy link
Contributor

@BHoMBot check ready-to-merge

@bhombot-ci
Copy link

bhombot-ci bot commented Mar 19, 2026

@jamesramsden-bh to confirm, the following actions are now queued:

  • check ready-to-merge

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check ready-to-merge

@bhombot-ci
Copy link

bhombot-ci bot commented Mar 19, 2026

@Tom-Kingstone to confirm, the following actions are now queued:

  • check ready-to-merge

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check ready-to-merge

@bhombot-ci
Copy link

bhombot-ci bot commented Mar 19, 2026

@Tom-Kingstone to confirm, the following actions are now queued:

  • check ready-to-merge

@jamesramsden-bh jamesramsden-bh merged commit 2acb028 into develop Mar 19, 2026
12 checks passed
@jamesramsden-bh jamesramsden-bh deleted the Python_Toolkit-#204-PlotStyleContext branch March 19, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New capability or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Patch Tkinter UI Issues Change plot style functionality to be context based rather than global

3 participants