Skip to content

Commit e99efae

Browse files
committed
Fix: world plot limits
1 parent f4e83bd commit e99efae

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

doc/doc.ipynb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
"source": [
235235
"def plot_world(\n",
236236
" data,\n",
237-
" title: str,\n",
237+
" title: str | None = None,\n",
238238
" fn: str | None = None,\n",
239239
" cbar_label: str | None = None,\n",
240240
" cmap: str | None = None,\n",
@@ -243,6 +243,8 @@
243243
" vmax=None,\n",
244244
" x: str | None = None,\n",
245245
" y: str | None = None,\n",
246+
" xlim: tuple | None = None,\n",
247+
" ylim: tuple | None = None,\n",
246248
"):\n",
247249
" fig = WorldPlot().plot(\n",
248250
" data=data,\n",
@@ -256,6 +258,8 @@
256258
" vmax=vmax,\n",
257259
" x=x,\n",
258260
" y=y,\n",
261+
" xlim=xlim,\n",
262+
" ylim=ylim,\n",
259263
" )\n",
260264
" fig.clear()"
261265
]
@@ -350,6 +354,7 @@
350354
" \"DIC (10 m, µmol kg-1)\",\n",
351355
" vmin=1750,\n",
352356
" vmax=2250,\n",
357+
" ylim=(-8625155.13, 8625155.13),\n",
353358
")"
354359
]
355360
},
@@ -367,6 +372,7 @@
367372
" \"DIC uncertainty (10 m, µmol kg-1)\",\n",
368373
" vmin=0.0,\n",
369374
" vmax=50.0,\n",
375+
" ylim=(-8625155.13, 8625155.13),\n",
370376
")"
371377
]
372378
},
@@ -384,6 +390,7 @@
384390
" \"DIC uncertainty (10 m, µmol kg-1)\",\n",
385391
" vmin=0.0,\n",
386392
" vmax=50.0,\n",
393+
" ylim=(-8625155.13, 8625155.13),\n",
387394
")"
388395
]
389396
},

kaleidoscope/val/plots.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def plot(
7171
cbar_kwargs=cbar_kwargs,
7272
)
7373
ax.autoscale_view()
74-
self.decorate(ax, xlocs, ylocs)
74+
self.decorate(ax, xlocs, ylocs, xlim, ylim)
7575
if title is not None:
7676
ax.set_title(title)
7777
if fn is not None:
@@ -81,7 +81,7 @@ def plot(
8181
plt.close()
8282
return fig
8383

84-
def decorate(self, ax, xlocs, ylocs):
84+
def decorate(self, ax, xlocs, ylocs, xlim, ylim):
8585
"""Decorates the map with land features and grid lines."""
8686
from cartopy.mpl.geoaxes import GeoAxes
8787

@@ -95,6 +95,10 @@ def decorate(self, ax, xlocs, ylocs):
9595
xlocs=xlocs,
9696
ylocs=ylocs,
9797
)
98+
if xlim is not None:
99+
ax.set_xlim(xlim)
100+
if ylim is not None:
101+
ax.set_ylim(ylim)
98102

99103
@property
100104
def land(self):

0 commit comments

Comments
 (0)