Skip to content

Commit

Permalink
add mask to colorbar, correct extreme values in legend sizes, correct…
Browse files Browse the repository at this point in the history
… example
  • Loading branch information
sarahclaude committed Apr 3, 2024
1 parent 2911423 commit bee56cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
18 changes: 8 additions & 10 deletions docs/notebooks/figanos_docs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -623,15 +623,13 @@
"outputs": [],
"source": [
"# create a fictional observational dataset from scratch\n",
"nb = 10\n",
"\n",
"names = ['station_' + str(i) for i in np.arange(nb)]\n",
"lat = 45 + np.random.rand(nb)*3\n",
"lon = np.linspace(-76,-70, nb)\n",
"tas = 20 + np.random.rand(9)*7\n",
"tas = np.append(tas, np.nan)\n",
"yrs = (10+30 * np.random.rand(9)).astype(int)\n",
"yrs = np.append( np.nan, yrs)\n",
"names = ['station_' + str(i) for i in np.arange(10)]\n",
"lat = 45 + np.random.rand(10)*3\n",
"lon = np.linspace(-76,-70, 10)\n",
"tas = 20 + np.random.rand(10)*7\n",
"tas[9] = np.nan\n",
"yrs = (10+30 * np.random.rand(10))\n",
"yrs[0] = np.nan\n",
"\n",
"attrs = {'units': 'degC', 'standard_name': 'air_temperature', 'long_name': 'Near-Surface Daily Maximum Air Temperature'}\n",
"\n",
Expand Down Expand Up @@ -660,7 +658,7 @@
" transform=ccrs.PlateCarree(),\n",
" sizes ='years',\n",
" size_range=(15, 100),\n",
" #divergent=23.5,\n",
" divergent=23.5,\n",
" features=features,\n",
" plot_kw={\n",
" \"xlim\": (-78,-68),\n",
Expand Down
4 changes: 2 additions & 2 deletions figanos/matplotlib/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,8 +1661,8 @@ def scattermap(
plot_kw.setdefault("s", pt_sizes[0])

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

norm = custom_cmap_norm(
cmap,
Expand Down
2 changes: 1 addition & 1 deletion figanos/matplotlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ def size_legend_elements(
lw=0,
markerfacecolor="w",
label=label,
markersize=np.sqrt(s),
markersize=np.sqrt(np.abs(s)),
)
)

Expand Down

0 comments on commit bee56cc

Please sign in to comment.