From b557edf35e0cb0e8f6a4c9186d2ac307167c12fc Mon Sep 17 00:00:00 2001 From: Edwin Supple Date: Tue, 1 Oct 2024 16:01:22 -0600 Subject: [PATCH 1/2] Reapply "Adjust scalebar logic to combine any specified parameters with defaults" This reverts commit 34a9658a43aa8e0ae0ca73d1f71eee99597f0ac5. --- py4DSTEM/visualize/show.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/py4DSTEM/visualize/show.py b/py4DSTEM/visualize/show.py index dcb1cf285..d5a50cb33 100644 --- a/py4DSTEM/visualize/show.py +++ b/py4DSTEM/visualize/show.py @@ -186,7 +186,7 @@ def show( and >>> show(dp, calibration=calibration, scalebar={'length':0.5,'width':2, - 'position':'ul','label':True'}) + 'position':'ul','label':True}) will display a more customized scalebar. @@ -316,7 +316,7 @@ def show( if returnfig==False (default), the figure is plotted and nothing is returned. if returnfig==True, return the figure and the axis. """ - if scalebar is True: + if scalebar is True or scalebar is None: scalebar = {} # Alias dep @@ -428,7 +428,7 @@ def show( er = ".calibration attribute must be a Calibration instance" assert isinstance(cal, Calibration), er if isinstance(ar, DiffractionSlice): - scalebar = { + defaultscalebar = { "Nx": ar.data.shape[0], "Ny": ar.data.shape[1], "pixelsize": cal.get_Q_pixel_size(), @@ -436,10 +436,13 @@ def show( "space": "Q", "position": "br", } + for key, value in defaultscalebar.items(): + if key not in scalebar.keys(): + scalebar[key] = value pixelsize = cal.get_Q_pixel_size() pixelunits = cal.get_Q_pixel_units() elif isinstance(ar, RealSlice): - scalebar = { + defaultscalebar = { "Nx": ar.data.shape[0], "Ny": ar.data.shape[1], "pixelsize": cal.get_R_pixel_size(), @@ -447,6 +450,9 @@ def show( "space": "Q", "position": "br", } + for key, value in defaultscalebar.items(): + if key not in scalebar.keys(): + scalebar[key] = value pixelsize = cal.get_R_pixel_size() pixelunits = cal.get_R_pixel_units() # get the data From baebf747ea2085d1b7dc22b25d4635b0b8fa3461 Mon Sep 17 00:00:00 2001 From: Edwin Supple Date: Tue, 1 Oct 2024 16:05:53 -0600 Subject: [PATCH 2/2] fix show_complex figsize popping --- py4DSTEM/visualize/vis_special.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py4DSTEM/visualize/vis_special.py b/py4DSTEM/visualize/vis_special.py index 2db48e371..82c840a4e 100644 --- a/py4DSTEM/visualize/vis_special.py +++ b/py4DSTEM/visualize/vis_special.py @@ -845,7 +845,7 @@ def show_complex( add_scalebar(ax[0, 0], scalebar) else: figsize = kwargs.pop("axsize", None) - figsize = kwargs.pop("figsize", figsize) + figsize = kwargs.pop("figsize", (5, 5)) fig, ax = show( rgb,