Skip to content

Commit

Permalink
Merge pull request #7 from ecmwf/merge-plots-maps
Browse files Browse the repository at this point in the history
Improvements to examples
  • Loading branch information
JamesVarndell authored Jun 19, 2024
2 parents ad08fd9 + 79676a2 commit e02b100
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 1,462 deletions.
9 changes: 9 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
formats: []
build:
os: "ubuntu-22.04"
tools:
python: "3.9"
python:
install:
- requirements: docs/requirements.txt
21 changes: 21 additions & 0 deletions docs/examples/gallery/gallery.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,27 @@
"* [Cities in Japan](ancillary/japan-cities.ipynb)\n",
"* [Shapefiles](ancillary/shapefiles.ipynb)"
]
},
{
"cell_type": "markdown",
"id": "9f89aba9",
"metadata": {},
"source": [
"### Time series"
]
},
{
"cell_type": "markdown",
"id": "115789bc",
"metadata": {
"tags": [
"nbsphinx-gallery"
]
},
"source": [
"* [Global average temperature climatology](time-series/global-average-temperature.ipynb)\n",
"* [CMIP6 climate projections](time-series/cmip6.ipynb)"
]
}
],
"metadata": {
Expand Down
14 changes: 11 additions & 3 deletions docs/examples/gallery/grid-types/healpix-pixels.ipynb

Large diffs are not rendered by default.

117 changes: 40 additions & 77 deletions docs/examples/gallery/gridded-data/efas.ipynb

Large diffs are not rendered by default.

1,433 changes: 58 additions & 1,375 deletions docs/examples/gallery/time-series/cmip6.ipynb

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions src/earthkit/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

from earthkit.plots import styles
from earthkit.plots.components.figures import Figure

# from earthkit.plots.components.globes import globe
from earthkit.plots.components.maps import Map
from earthkit.plots.components.subplots import Subplot
from earthkit.plots.definitions import FONTS_DIR
Expand All @@ -39,7 +37,6 @@
"Figure",
"Subplot",
"Map",
# "globe",
"schema",
"styles",
]
Expand Down
7 changes: 5 additions & 2 deletions src/earthkit/plots/components/globes.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,14 @@ def globe(

figure = Figure(left=0, right=1, bottom=0, top=1, size=(figsize, figsize))

crs = data.projection().to_cartopy_crs()
try:
crs = data.projection().to_cartopy_crs()
except AttributeError:
crs = ccrs.PlateCarree()
if crs.__class__.__name__ != "PlateCarree":
crs = ccrs.PlateCarree()

subplot = figure.add_map(crs=crs)
subplot = figure.add_map(crs=crs, domain=[-180, 180, -90, 90])
getattr(subplot, how)(data, style=style, transform_first=True)
extent = subplot.ax.get_extent()
if extent != (-180.0, 180.0, -90.0, 90.0):
Expand Down
7 changes: 5 additions & 2 deletions src/earthkit/plots/components/subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,11 @@ def envelope(self, data_1, data_2=0, alpha=0.4, **kwargs):
return mappable

@schema.envelope.apply()
def quantiles(self, data, quantiles=[0, 1], dim=None, alpha=0.4, **kwargs):
def quantiles(self, data, quantiles=[0, 1], dim=None, alpha=0.15, **kwargs):
prop_cycle = plt.rcParams["axes.prop_cycle"]
facecolor = kwargs.pop("facecolor", next(cycle(prop_cycle.by_key()["color"])))
facecolor = kwargs.pop(
"facecolor", kwargs.get("color", next(cycle(prop_cycle.by_key()["color"])))
)
color = kwargs.pop("color", next(cycle(prop_cycle.by_key()["color"])))
if isinstance(data, earthkit.data.core.Base):
data = data.to_xarray()
Expand All @@ -541,6 +543,7 @@ def quantiles(self, data, quantiles=[0, 1], dim=None, alpha=0.4, **kwargs):
)
else:
x, y, _ = self._extract_plottables_2(y=lines, **kwargs)
kwargs.pop("label", None)
mappable = self.ax.plot(
x, y, color=color, **{k: v for k, v in kwargs.items() if k != "x"}
)
Expand Down
1 change: 1 addition & 0 deletions src/earthkit/plots/geo/healpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def nnshow(var, nx=1000, ny=1000, ax=None, nest=False, style=None, **kwargs):
ax: axis to plot on
kwargs: additional arguments to imshow
"""
kwargs.pop("transform_first", None)
xlims = ax.get_xlim()
ylims = ax.get_ylim()
# NOTE: we want the center coordinate of each pixel, thus we have to
Expand Down

0 comments on commit e02b100

Please sign in to comment.