Skip to content

Added plot style context managers to all plot methods#208

Open
Tom-Kingstone wants to merge 14 commits intodevelopfrom
Python_Toolkit-#204-PlotStyleContext
Open

Added plot style context managers to all plot methods#208
Tom-Kingstone wants to merge 14 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

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

2 participants