Commit 275a018e authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added a 'title' keyword to the '.show_profile' methods. Fixed duplicate...


Added a 'title' keyword to the '.show_profile' methods. Fixed duplicate 'plt.show()'. Bumped version.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 9f0eefc8
Pipeline #25446 passed with stages
in 2 minutes and 12 seconds
......@@ -2,6 +2,12 @@
History
=======
0.13.1 (2021-07-09)
-------------------
* Added a 'title' keyword to the '.show_profile' methods. Fixed duplicate 'plt.show()'.
0.13.0 (2021-07-08)
-------------------
......
......@@ -1473,20 +1473,20 @@ class GeoArray(object):
plt.grid()
plt.title(title)
plt.show()
if return_fig:
return fig
else:
plt.show()
def show_xprofile(self, row, band, xlim=None, ylim=None, figsize=(10, 5), show_nodata=True, return_fig=False):
def show_xprofile(self, row, band, xlim=None, ylim=None, title=None, figsize=(10, 5), show_nodata=True,
return_fig=False):
"""Show an x-profile at the given row/band image position.
:param row: image row number (counts from 0)
:param band: image band number (counts from 0)
:param xlim: x-axis limits to be used in the plot
:param ylim: y-axis limits to be used in the plot
:param title: a custom plot title
:param figsize: figure size (tuple)
:param show_nodata: whether to show no-data values in the plot
:param return_fig: whether to return the figure instead of showing it directly
......@@ -1494,17 +1494,19 @@ class GeoArray(object):
"""
x = range(self.columns)
y = self[row, :, band]
title = f'X-Profile at row {range(self.rows)[row]}, band {range(self.bands)[band]}'
title = title or f'X-Profile at row {range(self.rows)[row]}, band {range(self.bands)[band]}'
return self._show_profile(x, y, 'column', 'value', title, xlim, ylim, figsize, show_nodata, return_fig)
def show_yprofile(self, column, band, xlim=None, ylim=None, figsize=(10, 5), show_nodata=True, return_fig=False):
def show_yprofile(self, column, band, xlim=None, ylim=None, title=None, figsize=(10, 5), show_nodata=True,
return_fig=False):
"""Show a y-profile at the given column/band image position.
:param column: image column number (counts from 0)
:param band: image band number (counts from 0)
:param xlim: x-axis limits to be used in the plot
:param ylim: y-axis limits to be used in the plot
:param title: a custom plot title
:param figsize: figure size (tuple)
:param show_nodata: whether to show no-data values in the plot
:param return_fig: whether to return the figure instead of showing it directly
......@@ -1512,17 +1514,19 @@ class GeoArray(object):
"""
x = range(self.rows)
y = self[:, column, band]
title = f'Y-Profile at column {range(self.columns)[column]}, band {range(self.bands)[band]}'
title = title or f'Y-Profile at column {range(self.columns)[column]}, band {range(self.bands)[band]}'
return self._show_profile(x, y, 'row', 'value', title, xlim, ylim, figsize, show_nodata, return_fig)
def show_zprofile(self, row, column, xlim=None, ylim=None, figsize=(10, 5), show_nodata=True, return_fig=False):
def show_zprofile(self, row, column, xlim=None, ylim=None, title=None, figsize=(10, 5), show_nodata=True,
return_fig=False):
"""Show a z-profile at the given row/column image position.
:param row: image row number (counts from 0)
:param column: image column number (counts from 0)
:param xlim: x-axis limits to be used in the plot
:param ylim: y-axis limits to be used in the plot
:param title: a custom plot title
:param figsize: figure size (tuple)
:param show_nodata: whether to show no-data values in the plot
:param return_fig: whether to return the figure instead of showing it directly
......@@ -1540,7 +1544,7 @@ class GeoArray(object):
x_label = 'band'
y = self[row, column, :]
title = f'Z-Profile at row {range(self.rows)[row]}, column {range(self.columns)[column]}'
title = title or f'Z-Profile at row {range(self.rows)[row]}, column {range(self.columns)[column]}'
return self._show_profile(x, y, x_label, 'value', title, xlim, ylim, figsize, show_nodata, return_fig)
......
......@@ -20,5 +20,5 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '0.13.0'
__versionalias__ = '20210708.02'
__version__ = '0.13.1'
__versionalias__ = '20210709.01'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment