Skip to content

Commit

Permalink
plt.scatter needs norm argument in Station 2
Browse files Browse the repository at this point in the history
Per a comment on the original PR to bring in the station 2 example, the colors
weren't actually assigned based on the randomized values.
  • Loading branch information
mnlevy1981 committed Dec 10, 2024
1 parent a5811ce commit df27297
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
.DS_Store
.ipynb_checkpoints/
*.grd.gz
**/__pycache__/
6 changes: 3 additions & 3 deletions Gallery/Station/NCL_station_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@

nbins = len(colors) # One bin for each color

# Define colormap for plotting based on these colors
# Define colormap and norm for plotting based on these colors
cmap = mpl.colors.ListedColormap(colors)
norm = mpl.colors.BoundaryNorm([-1.2] + bin_bounds + [35], len(colors))

###################################################
# Utility Function: Make Shared Plot:
Expand Down Expand Up @@ -100,7 +101,7 @@ def make_shared_plot(title):
zorder=0)

# Scatter-plot the location data on the map
scatter = plt.scatter(lon, lat, c=dummy_data, cmap=cmap, zorder=1)
scatter = plt.scatter(lon, lat, c=dummy_data, cmap=cmap, norm=norm, zorder=1)

plt.title(title, fontsize=16, y=1.04)

Expand Down Expand Up @@ -152,7 +153,6 @@ def make_shared_plot(title):

# Add a horizontal colorbar
cax = plt.axes((0.225, 0.05, 0.55, 0.025))
norm = mpl.colors.BoundaryNorm([-1.2] + bin_bounds + [35], len(colors))
mpl.colorbar.ColorbarBase(cax,
cmap=cmap,
orientation='horizontal',
Expand Down

0 comments on commit df27297

Please sign in to comment.