From a3fed27adb006fe58a73403ad0ce686a4e49683d Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Sat, 4 Nov 2023 20:51:18 -0700 Subject: [PATCH] plots.py replace plotly_unit() with pymatviz.utils.styled_html_tag --- matbench_discovery/plots.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/matbench_discovery/plots.py b/matbench_discovery/plots.py index 563ae3e2..9a247bac 100644 --- a/matbench_discovery/plots.py +++ b/matbench_discovery/plots.py @@ -20,6 +20,7 @@ from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar from plotly.validators.scatter.line import DashValidator from plotly.validators.scatter.marker import SymbolValidator +from pymatviz.utils import styled_html_tag from tqdm import tqdm from matbench_discovery import STABILITY_THRESHOLD @@ -37,16 +38,9 @@ plotly_line_styles *= len(plotly_markers) // len(plotly_line_styles) plotly_colors *= len(plotly_markers) // len(plotly_colors) - -def plotly_unit(text: str) -> str: - """Wrap text in a span with decreased font size and weight to display units in - plotly labels. - """ - style = "font-size: 0.8em; font-weight: lighter;" - return f"({text})" - - -ev_per_atom = plotly_unit("eV/atom") +ev_per_atom = styled_html_tag( + "(eV/atom)", tag="span", style="font-size: 0.8em; font-weight: lighter;" +) # --- start global plot settings quantity_labels = dict(