Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Python_Engine/Python/src/python_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@
if os.name == "nt":
# override "HOME" in case this is set to something other than default for windows
os.environ["HOME"] = (Path("C:/Users/") / getpass.getuser()).as_posix()


# set plotting style for modules within this toolkit
plt.style.use(BHOM_DIRECTORY / "bhom.mplstyle")
88 changes: 88 additions & 0 deletions Python_Engine/Python/src/python_toolkit/bhom_dark.mplstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Default matplotlib settings for this toolkit.

# Text
text.color: white

# Set custom colors. All colors are in web style hex format.
axes.prop_cycle: cycler('color', ['702F8A', 'E63187', '00A9E0', 'FFCF04', '6CC24E', 'EB671C', '00A499', 'D50032', '24135F', '6D104E', '006DA8', 'D06A13', '5D822D', 'F0AC1B', '1C3660', 'BC204B', '8F72B0', 'FCD16D', '8DB9CA', 'EE7837', 'AFC1A2', 'B72B77', 'A0D2C9', 'E6484D'])

# Face settings
axes.facecolor: black
axes.edgecolor: white

# Style spines
axes.linewidth: 0.8
axes.spines.top: False
axes.spines.left: True
axes.spines.right: False
axes.spines.bottom: True

# Set line styling for line plots
lines.linewidth: 1
lines.solid_capstyle: round
lines.dash_capstyle: round

# Grid style
axes.axisbelow: True
axes.grid: true
axes.grid.axis: both
grid.color: 958B82
grid.linestyle: --
grid.linewidth: 0.5

# Setting font sizes and spacing
axes.labelsize: medium
axes.labelweight: semibold
axes.labelcolor: white
axes.ymargin: 0.1
font.family: sans-serif
font.sans-serif: Segoe UI
font.size: 10
xtick.labelsize: medium
xtick.labelcolor: white
xtick.major.pad: 3.5
ytick.labelsize: medium
ytick.labelcolor: white
ytick.major.pad: 3.5

# date formatter
date.autoformatter.day: %b-%d
date.autoformatter.hour: %b-%d %H
date.autoformatter.microsecond: %M:%S.%f
date.autoformatter.minute: %d %H:%M
date.autoformatter.month: %b
date.autoformatter.second: %H:%M:%S
date.autoformatter.year: %Y

# Title
axes.titlelocation: left
axes.titlepad: 6
axes.titlesize: large
axes.titleweight: bold

# Remove major and minor ticks except for on the x-axis.
xtick.color: white
xtick.major.size: 3
xtick.minor.size: 2
ytick.color: white
ytick.major.size: 3
ytick.minor.size: 2

# Set spacing for figure and also DPI.
figure.subplot.left: 0.08
figure.subplot.right: 0.95
figure.subplot.bottom: 0.07
figure.figsize: 12, 5
figure.dpi: 150
figure.facecolor: black

# Properties for saving the figure. Ensure a high DPI when saving so we have a good resolution.
savefig.dpi: 300
savefig.facecolor: black
savefig.bbox: tight
savefig.pad_inches: 0.2

# Legend Styling
legend.framealpha: 0
legend.frameon: False
legend.facecolor: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,16 @@ def validate(self) -> tuple[bool, Optional[str], Optional[Literal['info', 'warni
build_options=PackingOptions(padx=10, pady=10, fill='both', expand=True)
)
figure_container.build()

style = "python_toolkit.bhom_dark"

# Create and embed the initial matplotlib figure
fig_initial, ax_initial = plt.subplots(figsize=(5, 4), dpi=80)
ax_initial.plot([1, 2, 3, 4], [1, 4, 2, 3], marker='o')
ax_initial.set_title("Initial Plot")
ax_initial.set_xlabel("X")
ax_initial.set_ylabel("Y")
with plt.style.context(style):
fig_initial, ax_initial = plt.subplots(figsize=(5, 4), dpi=80)
ax_initial.plot([1, 2, 3, 4], [1, 4, 2, 3], marker='o')
ax_initial.set_title("Initial Plot")
ax_initial.set_xlabel("X")
ax_initial.set_ylabel("Y")
figure_container.embed_figure(fig_initial)

def push_new_plot() -> None:
Expand Down
Loading