Skip to content

Commit 54de023

Browse files
fixed bugs in ESIResult.quick_plot()
1 parent 61d0dee commit 54de023

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/python/spatialize/gs/esi/_main.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,16 @@ def quick_plot(self, w=None, h=None,
176176
:param fig_args: Additional figure arguments.
177177
:return: The figure.
178178
"""
179-
if self._xi.shape[1] > 2:
180-
raise SpatializeError("quick_plot() for 3D data is not supported")
179+
if self.griddata:
180+
if self._xi.shape[0] > 2:
181+
raise SpatializeError("quick_plot() for 3D data is not supported")
182+
x_min, x_max = self._xi[0].min(), self._xi[0].max()
183+
y_min, y_max = self._xi[1].min(), self._xi[1].max()
184+
else:
185+
if self._xi.shape[-1] > 2:
186+
raise SpatializeError("quick_plot() for 3D data is not supported")
187+
x_min, x_max = self._xi[:,0].min(), self._xi[:,0].max()
188+
y_min, y_max = self._xi[:,1].min(), self._xi[:,1].max()
181189

182190
plot_fig_args = fig_args.copy()
183191
plot_fig_args.setdefault('figsize', (10,8))
@@ -189,11 +197,11 @@ def quick_plot(self, w=None, h=None,
189197
ax1, ax2 = gs.subplots()
190198

191199
ax1.set_title('Estimation')
192-
self.plot_estimation(ax1, w=w, h=h, theme=None, cmap=style.cmap)
200+
self.plot_estimation(ax1, w=w, h=h, theme=None, cmap=style.cmap, extent=[x_min, x_max, y_min, y_max])
193201
ax1.set_aspect('equal')
194202

195203
ax2.set_title('Precision')
196-
self.plot_precision(ax2, w=w, h=h, theme=None, cmap=style.precision_cmap)
204+
self.plot_precision(ax2, w=w, h=h, theme=None, cmap=style.precision_cmap, extent=[x_min, x_max, y_min, y_max])
197205
ax2.set_aspect('equal')
198206

199207
if not in_notebook():
@@ -405,7 +413,7 @@ def esi_griddata(points, values, xi, **kwargs):
405413
"""
406414
ng_xi, original_shape = flatten_grid_data(xi)
407415
estimation, esi_samples = _call_libspatialize(points, values, ng_xi, **kwargs)
408-
return ESIResult(estimation, esi_samples, griddata=True, original_shape=original_shape)
416+
return ESIResult(estimation, esi_samples, griddata=True, original_shape=original_shape, xi=xi)
409417

410418

411419
def esi_nongriddata(points, values, xi, **kwargs):

0 commit comments

Comments
 (0)