From df27297c7f5d3229d88240c2eef7df52d70b72a3 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Tue, 10 Dec 2024 10:08:56 -0700 Subject: [PATCH 1/2] plt.scatter needs norm argument in Station 2 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. --- .gitignore | 1 + Gallery/Station/NCL_station_2.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b9fe7d3cb..7351c606e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ .DS_Store .ipynb_checkpoints/ *.grd.gz +**/__pycache__/ diff --git a/Gallery/Station/NCL_station_2.py b/Gallery/Station/NCL_station_2.py index 4ea3322e4..51452e080 100644 --- a/Gallery/Station/NCL_station_2.py +++ b/Gallery/Station/NCL_station_2.py @@ -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: @@ -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) @@ -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', From 171e27ebae1b820d9f9337a8b7f8a3913545dd02 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Tue, 10 Dec 2024 10:18:29 -0700 Subject: [PATCH 2/2] YAPF changes to pass CI --- Gallery/Station/NCL_station_2.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Gallery/Station/NCL_station_2.py b/Gallery/Station/NCL_station_2.py index 51452e080..a82c1bc10 100644 --- a/Gallery/Station/NCL_station_2.py +++ b/Gallery/Station/NCL_station_2.py @@ -101,7 +101,12 @@ 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, norm=norm, zorder=1) + scatter = plt.scatter(lon, + lat, + c=dummy_data, + cmap=cmap, + norm=norm, + zorder=1) plt.title(title, fontsize=16, y=1.04)