17
17
from matplotlib .colors import SymLogNorm
18
18
from pymatgen .core import Composition , Element
19
19
from pymatviz .enums import Key
20
- from pymatviz .io import save_fig
21
- from pymatviz .utils import si_fmt
22
20
from tqdm import tqdm
23
21
24
22
from matbench_discovery import MP_DIR , PDF_FIGS , ROOT , SITE_FIGS
@@ -108,7 +106,7 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
108
106
"""Annotate each periodic table tile with the number of values in its histogram."""
109
107
face_color = cmap (norm (np .sum (len (hist_vals )))) if hist_vals else "none"
110
108
bbox = dict (facecolor = face_color , alpha = 0.4 , pad = 2 , edgecolor = "none" )
111
- return dict (text = si_fmt (len (hist_vals ), ".0f" ), bbox = bbox )
109
+ return dict (text = pmv . si_fmt (len (hist_vals ), ".0f" ), bbox = bbox )
112
110
113
111
114
112
# %% plot per-element magmom histograms
@@ -152,7 +150,7 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
152
150
cbar = matplotlib .colorbar .ColorbarBase (
153
151
cbar_ax , cmap = cmap , norm = norm , orientation = "horizontal"
154
152
)
155
- save_fig (fig_ptable_magmoms , f"{ PDF_FIGS } /mp-trj-magmoms-ptable-hists.pdf" )
153
+ pmv . save_fig (fig_ptable_magmoms , f"{ PDF_FIGS } /mp-trj-magmoms-ptable-hists.pdf" )
156
154
157
155
158
156
# %% plot per-element force histograms
@@ -195,7 +193,7 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
195
193
cbar_ax , cmap = cmap , norm = norm , orientation = "horizontal"
196
194
)
197
195
198
- save_fig (fig_ptable_forces , f"{ PDF_FIGS } /mp-trj-forces-ptable-hists.pdf" )
196
+ pmv . save_fig (fig_ptable_forces , f"{ PDF_FIGS } /mp-trj-forces-ptable-hists.pdf" )
199
197
200
198
201
199
# %% plot histogram of number of sites per element
@@ -238,7 +236,7 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
238
236
cbar_title_kwds = dict (fontsize = 16 ),
239
237
cbar_coords = (0.18 , 0.85 , 0.42 , 0.02 ),
240
238
anno_kwds = lambda hist_vals : dict (
241
- text = si_fmt (len (hist_vals ), ".0f" ),
239
+ text = pmv . si_fmt (len (hist_vals ), ".0f" ),
242
240
xy = (0.8 , 0.6 ),
243
241
bbox = dict (pad = 2 , edgecolor = "none" , facecolor = "none" ),
244
242
),
@@ -262,7 +260,7 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
262
260
cbar .set_label ("Number of atoms in MPtrj structures" , fontsize = 16 )
263
261
cbar .ax .xaxis .set_label_position ("top" )
264
262
265
- save_fig (fig_ptable_sites , f"{ PDF_FIGS } /mp-trj-n-sites-ptable-hists.pdf" )
263
+ pmv . save_fig (fig_ptable_sites , f"{ PDF_FIGS } /mp-trj-n-sites-ptable-hists.pdf" )
266
264
267
265
268
266
# %%
@@ -301,7 +299,7 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
301
299
img_name += "-symlog" if isinstance (log , SymLogNorm ) else "-log"
302
300
if excl_noble :
303
301
img_name += "-excl-noble"
304
- save_fig (ax_ptable , f"{ PDF_FIGS } /{ img_name } .pdf" )
302
+ pmv . save_fig (ax_ptable , f"{ PDF_FIGS } /{ img_name } .pdf" )
305
303
306
304
307
305
# %%
@@ -319,7 +317,7 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
319
317
img_name = "mp-trj-mp-ratio-element-counts-by-occurrence"
320
318
if normalized :
321
319
img_name += "-normalized"
322
- save_fig (ax_ptable , f"{ PDF_FIGS } /{ img_name } .pdf" )
320
+ pmv . save_fig (ax_ptable , f"{ PDF_FIGS } /{ img_name } .pdf" )
323
321
324
322
325
323
# %% plot formation energy per atom distribution
@@ -332,8 +330,8 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
332
330
fig .show ()
333
331
334
332
pdf_kwds = dict (width = 500 , height = 300 )
335
- # save_fig(fig, f"{PDF_FIGS}/mp-trj-e-form-hist.pdf", **pdf_kwds)
336
- # save_fig(fig, f"{SITE_FIGS}/mp-trj-e-form-hist.svelte")
333
+ # pmv. save_fig(fig, f"{PDF_FIGS}/mp-trj-e-form-hist.pdf", **pdf_kwds)
334
+ # pmv. save_fig(fig, f"{SITE_FIGS}/mp-trj-e-form-hist.svelte")
337
335
338
336
339
337
# %% plot forces distribution
@@ -343,8 +341,8 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
343
341
fig .update_yaxes (type = "log" )
344
342
fig .show ()
345
343
346
- # save_fig(fig, f"{PDF_FIGS}/mp-trj-forces-hist.pdf", **pdf_kwds)
347
- # save_fig(fig, f"{SITE_FIGS}/mp-trj-forces-hist.svelte")
344
+ # pmv. save_fig(fig, f"{PDF_FIGS}/mp-trj-forces-hist.pdf", **pdf_kwds)
345
+ # pmv. save_fig(fig, f"{SITE_FIGS}/mp-trj-forces-hist.svelte")
348
346
349
347
350
348
# %% plot hydrostatic stress distribution
@@ -354,8 +352,8 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
354
352
fig .update_yaxes (type = "log" )
355
353
fig .show ()
356
354
357
- # save_fig(fig, f"{PDF_FIGS}/mp-trj-stresses-hist.pdf", **pdf_kwds)
358
- # save_fig(fig, f"{SITE_FIGS}/mp-trj-stresses-hist.svelte")
355
+ # pmv. save_fig(fig, f"{PDF_FIGS}/mp-trj-stresses-hist.pdf", **pdf_kwds)
356
+ # pmv. save_fig(fig, f"{SITE_FIGS}/mp-trj-stresses-hist.svelte")
359
357
360
358
361
359
# %% plot magmoms distribution
@@ -365,8 +363,8 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
365
363
fig .update_yaxes (type = "log" )
366
364
fig .show ()
367
365
368
- # save_fig(fig, f"{PDF_FIGS}/mp-trj-magmoms-hist.pdf", **pdf_kwds)
369
- # save_fig(fig, f"{SITE_FIGS}/mp-trj-magmoms-hist.svelte")
366
+ # pmv. save_fig(fig, f"{PDF_FIGS}/mp-trj-magmoms-hist.pdf", **pdf_kwds)
367
+ # pmv. save_fig(fig, f"{SITE_FIGS}/mp-trj-magmoms-hist.svelte")
370
368
371
369
372
370
# %%
@@ -393,8 +391,8 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
393
391
394
392
fig .show ()
395
393
img_name = "mp-vs-mp-trj-vs-wbm-arity-hist"
396
- save_fig (fig , f"{ SITE_FIGS } /{ img_name } .svelte" )
397
- save_fig (fig , f"{ PDF_FIGS } /{ img_name } .pdf" , width = 450 , height = 280 )
394
+ pmv . save_fig (fig , f"{ SITE_FIGS } /{ img_name } .svelte" )
395
+ pmv . save_fig (fig , f"{ PDF_FIGS } /{ img_name } .pdf" , width = 450 , height = 280 )
398
396
399
397
400
398
# %% calc n_sites from per-site atomic numbers
@@ -472,5 +470,5 @@ def tile_count_anno(hist_vals: list[Any]) -> dict[str, Any]:
472
470
img_name = "mp-trj-n-sites-hist"
473
471
if log_y :
474
472
img_name += "-log"
475
- save_fig (fig , f"{ SITE_FIGS } /{ img_name } .svelte" )
476
- # save_fig(fig, f"{PDF_FIGS}/{img_name}.pdf", width=450, height=300)
473
+ pmv . save_fig (fig , f"{ SITE_FIGS } /{ img_name } .svelte" )
474
+ # pmv. save_fig(fig, f"{PDF_FIGS}/{img_name}.pdf", width=450, height=300)
0 commit comments