Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use gridmap code #238

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Internal changes
* Maintainer-specific documentation has been added to new documentation page `releasing.rst`.
* `figanos` now has a `CODE_OF_CONDUCT.rst` file adapting the Contributor Covenant v2.1 conventions. (:pull:`210`).

Bug fixes
^^^^^^^^^
* Creating the colormap in `fg.matplotlib.scattermap` is now done like `fg.matplotlib.gridmap` (:pull:`238`, :issue:`239`).


0.3.0 (2024-02-16)
------------------
Contributors to this version: Sarah-Claude Bourdeau-Goulet (:user:`Sarahclaude`), Pascal Bourgault (:user:`aulemahal`), Trevor James Smith (:user:`Zeitsperre`), Juliette Lavoie (:user:`juliettelavoie`), Gabriel Rondeau-Genesse (:user:`RondeauG`).
Expand Down
39 changes: 24 additions & 15 deletions src/figanos/matplotlib/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1747,22 +1747,33 @@ def scattermap(
else:
plot_kw_pop.setdefault("s", pt_sizes[0])

# norm
plot_kw_pop.setdefault("vmin", np.nanmin(plot_data.values[mask]))
plot_kw_pop.setdefault("vmax", np.nanmax(plot_data.values[mask]))

norm = custom_cmap_norm(
cmap,
vmin=plot_kw_pop["vmin"],
vmax=plot_kw_pop["vmax"],
levels=levels,
divergent=divergent,
)
if levels is not None:
if isinstance(levels, Iterable):
lin = levels
else:
lin = custom_cmap_norm(
cmap,
np.nanmin(plot_data.values[mask]),
np.nanmax(plot_data.values[mask]),
levels=levels,
divergent=divergent,
linspace_out=True,
)
plot_kw_pop.setdefault("levels", lin)

elif (divergent is not False) and ("levels" not in plot_kw):
norm = custom_cmap_norm(
cmap,
np.nanmin(plot_data.values[mask]),
np.nanmax(plot_data.values[mask]),
levels=levels,
divergent=divergent,
)
plot_kw_pop.setdefault("norm", norm)

# set defaults and create copy without vmin, vmax (conflicts with norm)
# set defaults and
plot_kw_pop = {
"cmap": cmap,
"norm": norm,
"transform": transform,
"zorder": 8,
"marker": "o",
Expand All @@ -1788,8 +1799,6 @@ def scattermap(
else:
plot_kw_pop.setdefault("edgecolor", "none")

for key in ["vmin", "vmax"]:
plot_kw_pop.pop(key)
# plot
plot_kw_pop = {"x": "lon", "y": "lat", "hue": plot_data.name} | plot_kw_pop
if ax:
Expand Down