Skip to content

Commit c0c8a9e

Browse files
authored
Add plot kwargs to AFMulator (#364)
To enable overlaying the atoms to the generated AFM images.
1 parent 120e27f commit c0c8a9e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

ppafm/ocl/AFMulator.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -628,14 +628,15 @@ def check_scan_window(self):
628628
"the size of the scan window and the force field grid."
629629
)
630630

631-
def plot_images(self, X, outdir="afm_images", prefix="df"):
631+
def plot_images(self, X, outdir="afm_images", prefix="df", **plot_kwargs):
632632
"""
633633
Plot simulated AFM images and save them to a directory.
634634
635635
Arguments:
636636
X: np.ndarray. AFM images to plot.
637637
outdir: str. Path to directory where files are saved.
638638
prefix: str. Prefix string for saved files.
639+
plot_kwargs: Additional keyword arguments passed to :func:`.plotImages`.
639640
"""
640641
if not os.path.exists(outdir):
641642
os.makedirs(outdir)
@@ -652,14 +653,12 @@ def plot_images(self, X, outdir="afm_images", prefix="df"):
652653
self.scan_window[0][1],
653654
self.scan_window[1][1],
654655
]
655-
plotImages(
656-
os.path.join(outdir, prefix),
657-
X,
658-
slices=list(range(0, len(X))),
659-
zs=zTips,
660-
extent=extent,
661-
cmap=self.colorscale,
662-
)
656+
657+
for key in ["F", "slices", "extent", "zs", "cmap"]:
658+
if key in plot_kwargs:
659+
warnings.warn(f"\n plot_images(): '{key}' found in plot_kwargs but is set internally, removing from plot_kwargs.")
660+
del plot_kwargs[key]
661+
plotImages(os.path.join(outdir, prefix), X, slices=list(range(0, len(X))), zs=zTips, extent=extent, cmap=self.colorscale, **plot_kwargs)
663662

664663

665664
def _get_params(file_path):

0 commit comments

Comments
 (0)