-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overly large font size (or other elements) causing ptable_heatmap
tiles to shrink
#188
Comments
Thanks for reporting, and sorry for the trouble. Looks like bad font size to me (the default font size is too large in scientific notation mode, you might want to manually reduce the font size a bit for now, and certainly it's better for me to improve the default font size in such situation), can you provide the code to reproduce that plot? @CompRhys |
Sorry for the slow reply, if you check out this branch (janosh/matbench-discovery#125) and run the |
No problem I would look into this ASAP |
I'm able to reproduce similar issues with the following code extracted from the import pandas as pd
import pymatviz as pmv
from matplotlib.colors import SymLogNorm
from pymatviz.enums import Key
from matbench_discovery import PDF_FIGS, ROOT
from matbench_discovery import plots as plots
from matbench_discovery.data import DataFiles, df_wbm
DATA_PAGE = f"{ROOT}/site/src/routes/data"
# Load MP training set
df_mp = pd.read_csv(DataFiles.mp_energies.path, na_filter=False, na_values=[])
df_mp = df_mp.rename(columns={"formula_pretty": Key.formula})
df_mp.loc[
df_mp[Key.mat_id].isin(["mp-1080032", "mp-1179882", "mp-1009221"]), Key.formula
] = "NaN"
df_mp[df_mp[Key.formula].isna() | (df_mp[Key.formula] == "")]
wbm_occu_counts = pmv.count_elements(df_wbm[Key.formula], count_mode="occurrence")
wbm_comp_counts = pmv.count_elements(df_wbm[Key.formula], count_mode="composition")
mp_occu_counts = pmv.count_elements(df_mp[Key.formula], count_mode="occurrence")
mp_comp_counts = pmv.count_elements(df_mp[Key.formula], count_mode="composition")
all_counts = (
("wbm", "occurrence", wbm_occu_counts),
("wbm", "composition", wbm_comp_counts),
("mp", "occurrence", mp_occu_counts),
("mp", "composition", mp_comp_counts),
)
for dataset, count_mode, elem_counts in all_counts:
filename = f"{dataset}-element-counts-by-{count_mode}"
elem_counts.to_json(f"{DATA_PAGE}/{filename}.json")
ax_mp_cnt = pmv.ptable_heatmap(
elem_counts,
value_fmt=lambda x, _: pmv.utils.si_fmt(x, ".0f"),
cbar_label_fmt=lambda x, _: pmv.utils.si_fmt(x, ".0f"),
cbar_title=f"{dataset.upper()} Element Count",
log=(log := SymLogNorm(linthresh=100)),
return_type="figure",
)
if log:
filename += "-symlog" if isinstance(log, SymLogNorm) else "-log"
pmv.save_fig(ax_mp_cnt, f"{PDF_FIGS}/{filename}.pdf") |
Closing as I believe it is resolved by janosh/matbench-discovery#125 (comment), free feel to comment if it's not the case. |
ptable_heatmap
@DanielYang59 thanks for the advice in janosh/matbench-discovery#125 (comment)! i haven't tried it yet but if those custom kwargs fix the issue, we should make those values the new defaults. |
I would reply in that PR :) |
I believe this could be closed janosh/matbench-discovery#125 (comment) |
the issue of shrinking element tiles does still happen for large heat value numbers or if you pass a custom |
Yep I noticed this issue too (not just heat value, but any overly large font). The way tile size is handled is a bit complicated and confusing, looks like when the font is overly large, the tile shrinks (like taking the I assume any element that is larger than the tile size would cause the tile to shrink, perhaps it's best for us to somehow normalize the fontsize (and more). |
ptable_heatmap
ptable_heatmap
tiles to shrink
Recent changes appear to have broken the matplotlib heatmaps. @DanielYang59
The text was updated successfully, but these errors were encountered: