From 9bd914068f43385f5c522d8eddb152623bd4f0ac Mon Sep 17 00:00:00 2001 From: Daniel Scheffler Date: Wed, 29 Sep 2021 22:49:48 +0200 Subject: [PATCH] Added new parameters to Tie_Point_Grid.plot_shift_distribution(). Added documentation to COREG_LOCAL.view_CoRegPoints(). Bumped version and updated HISTORY.rst. Signed-off-by: Daniel Scheffler --- HISTORY.rst | 8 ++++++++ arosics/CoReg_local.py | 14 +++++++------- arosics/Tie_Point_Grid.py | 26 ++++++++++++++++++++++---- arosics/version.py | 4 ++-- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index fcf36c5..77f7fd8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,14 @@ History ======= +1.6.2 (2021-09-29) +------------------ + +* Fixed 'too many values to unpack' exception in COREG_LOCAL.view_CoRegPoints(). +* Added new parameters to Tie_Point_Grid.plot_shift_distribution(). +* Added documentation to COREG_LOCAL.view_CoRegPoints(). + + 1.6.1 (2021-09-29) ------------------ diff --git a/arosics/CoReg_local.py b/arosics/CoReg_local.py index 8a854be..69c3a97 100644 --- a/arosics/CoReg_local.py +++ b/arosics/CoReg_local.py @@ -523,13 +523,13 @@ def view_CoRegPoints(self, :param figsize_multiplier: if given, the figure size is multiplied with this value :param title: plot title :param vector_scale: scale factor for shift vector length (default: 1 -> no scaling) - :param savefigPath: - :param savefigDPI: - :param showFig: whether to show or to hide the figure - :param vmin: - :param vmax: - :param return_map: - :return: + :param savefigPath: path where to save the figure + :param savefigDPI: DPI resolution of the output figure when saved to disk (default: 96) + :param showFig: whether to show or to hide the figure (default: True) + :param vmin: minimum value of 'attribute2plot' to be included in the figure + :param vmax: maximum value of 'attribute2plot' to be included in the figure + :param return_map: whether to return the figure and axis objects (default: False) + :return: tuple of figure and axis objects or None in case return_map is set to False """ from matplotlib import pyplot as plt # noqa from matplotlib.offsetbox import AnchoredText diff --git a/arosics/Tie_Point_Grid.py b/arosics/Tie_Point_Grid.py index 2a0a983..6d35946 100755 --- a/arosics/Tie_Point_Grid.py +++ b/arosics/Tie_Point_Grid.py @@ -500,18 +500,26 @@ def plot_shift_distribution(self, xlim: list = None, ylim: list = None, fontsize: int = 12, - title: str = 'shift distribution' + title: str = 'shift distribution', + savefigPath: str = '', + savefigDPI: int = 96, + showFig: bool = True, + return_fig: bool = False ) -> tuple: """Create a 2D scatterplot containing the distribution of calculated X/Y-shifts. :param include_outliers: whether to include tie points that have been marked as false-positives :param unit: 'm' for meters or 'px' for pixels (default: 'm') - :param interactive: interactive mode uses plotly for visualization + :param interactive: whether to use interactive mode (uses plotly for visualization) :param figsize: (xdim, ydim) :param xlim: [xmin, xmax] :param ylim: [ymin, ymax] :param fontsize: size of all used fonts :param title: the title to be plotted above the figure + :param savefigPath: path where to save the figure + :param savefigDPI: DPI resolution of the output figure when saved to disk + :param showFig: whether to show or to hide the figure + :param return_fig: whether to return the figure and axis objects """ from matplotlib import pyplot as plt @@ -598,9 +606,19 @@ def plot_shift_distribution(self, leg = plt.legend(reversed(handles), reversed(labels), fontsize=fontsize, loc='upper right', scatterpoints=3) leg.get_frame().set_edgecolor('black') - plt.show() + # remove white space around the figure + plt.subplots_adjust(top=.94, bottom=.06, right=.96, left=.09) - return fig, ax + if savefigPath: + fig.savefig(savefigPath, dpi=savefigDPI, pad_inches=0.3, bbox_inches='tight') + + if return_fig: + return fig, ax + + if showFig and not self.q: + plt.show(block=True) + else: + plt.close(fig) def dump_CoRegPoints_table(self, path_out=None): if self.CoRegPoints_table.empty: diff --git a/arosics/version.py b/arosics/version.py index 901626e..5f1dce4 100644 --- a/arosics/version.py +++ b/arosics/version.py @@ -24,5 +24,5 @@ # limitations under the License. -__version__ = '1.6.1' -__versionalias__ = '2021-09-29_01' +__version__ = '1.6.2' +__versionalias__ = '2021-09-29_02'