Skip to content

Commit

Permalink
plots.py replace plotly_unit() with pymatviz.utils.styled_html_tag
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Nov 5, 2023
1 parent c778a03 commit a3fed27
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions matbench_discovery/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"<span {style=}>({text})</span>"


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(
Expand Down

0 comments on commit a3fed27

Please sign in to comment.