Skip to content

Commit 95cfc76

Browse files
committed
WIP, not working: add f-block vertical offset
1 parent acfe4ab commit 95cfc76

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pymatviz/ptable.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ def ptable_heatmap(
732732
# Figure-scope
733733
on_empty: Literal["hide", "show"] = "hide",
734734
hide_f_block: bool | Literal["AUTO"] = "AUTO",
735-
# f_block_voffset: float = 0.5,
735+
f_block_voffset: float = 0,
736736
plot_kwargs: dict[str, Any] | None = None,
737737
# Axis-scope
738738
ax_kwargs: dict[str, Any] | None = None,
@@ -779,6 +779,7 @@ def ptable_heatmap(
779779
data. Defaults to "hide".
780780
hide_f_block (bool | "AUTO"): Hide f-block (Lanthanum and Actinium series).
781781
Defaults to "AUTO", meaning hide if no data is provided.
782+
f_block_voffset (float): The vertical offset of f-block elements.
782783
plot_kwargs (dict): Additional keyword arguments to
783784
pass to the plt.subplots function call.
784785
@@ -903,6 +904,7 @@ def tile_colors(
903904
def add_child_plots( # type: ignore[override]
904905
self,
905906
*,
907+
# f_block_voffset: float = 0,
906908
tick_kwargs: dict[str, Any] | None = None,
907909
ax_kwargs: dict[str, Any] | None = None,
908910
on_empty: Literal["hide", "show"] = "hide",
@@ -912,6 +914,7 @@ def add_child_plots( # type: ignore[override]
912914
TODO: make the element-loop part a decorator.
913915
914916
Args:
917+
f_block_voffset (float): The vertical offset of f-block elements.
915918
tick_kwargs (dict): Keyword arguments to pass to ax.tick_params().
916919
ax_kwargs (dict): Keyword arguments to pass to ax.set().
917920
on_empty ("hide" | "show"): Whether to show or hide tiles for
@@ -944,6 +947,15 @@ def add_child_plots( # type: ignore[override]
944947
if (plot_data is None or len(plot_data) == 0) and on_empty == "hide":
945948
continue
946949

950+
# TODO: offset is not working properly, even when offset is 0,
951+
# the tile size still changes
952+
953+
# # Apply vertical offset for f-block
954+
# if element.is_lanthanoid or element.is_actinoid:
955+
# pos = ax.get_position()
956+
# ax.set_position([pos.x0, pos.y0 + f_block_voffset,
957+
# pos.width, pos.height])
958+
947959
# Add child heatmap plot
948960
ax.pie(
949961
np.ones(1),
@@ -1038,6 +1050,7 @@ def add_elem_values(
10381050
colormap=colormap, # type: ignore[arg-type]
10391051
plot_kwargs=plot_kwargs, # type: ignore[arg-type]
10401052
hide_f_block=hide_f_block, # type: ignore[arg-type]
1053+
f_block_voffset=f_block_voffset, # type: ignore[arg-type]
10411054
)
10421055

10431056
# Call child plotter: heatmap

0 commit comments

Comments
 (0)