Skip to content

Commit

Permalink
Address CI failures from upstream Matplotlib changes (#621)
Browse files Browse the repository at this point in the history
* Update NCL_xy_16.py to use the "reverse" option for the legend rather than a workaround

* Update NCL_overlay_11b.py to address matplotlib 3.10 changes

* Update NCL_hov_3.py to address matplotlib 3.10 deprecations
  • Loading branch information
kafitzgerald authored Oct 21, 2024
1 parent 63ba2c6 commit 1431c48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
5 changes: 2 additions & 3 deletions Gallery/Contours/NCL_hov_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@
hatches=['....'])

# Make all dot-filled areas light gray so contour lines are still visible
for i, collection in enumerate(cf.collections):
collection.set_edgecolor('lightgray')
collection.set_linewidth(0.)
cf.set_edgecolor('lightgray')
cf.set_linewidth(0.)

# Fill area at the lowest contour level, -6, with line hatching
cf = ax.contourf(lon,
Expand Down
10 changes: 1 addition & 9 deletions Gallery/Overlays/NCL_overlay_11b.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,7 @@
# another contour plot and clip that contour plot with the patch. In
# other words, every island on this plot corresponds to its own
# contour plot!)
cf = ax.contourf(lon, lat, T, levels=clevs, cmap=newcmp)

# Clip each contour of the contour plot
# (NOTE: Each contour of the contour plot is actually its own "plot". There
# is no easy mechanism in matplotlib to clip the entire contour plot
# at once, so we must loop through the "collections" in the contour
# plot and clip each one separately.)
for col in cf.collections:
col.set_clip_path(patch)
cf = ax.contourf(lon, lat, T, levels=clevs, cmap=newcmp, clip_path=patch)

# Add horizontal colorbar
cax = plt.axes((0.14, 0.08, 0.74, 0.02))
Expand Down
13 changes: 6 additions & 7 deletions Gallery/XY/NCL_xy_16.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@

# Add legend
handles, labels = ax.get_legend_handles_labels()
# Default order is the order in which the data was plotted
handles = reversed(handles) # Reverse order of legend elements
labels = reversed(labels)

plt.legend(handles,
labels,
loc='center right',
frameon=False,
fontsize=14,
labelspacing=1)
labelspacing=1,
reverse=True)

plt.show()

Expand Down Expand Up @@ -183,13 +182,13 @@
# Add legend
handles, labels = ax.get_legend_handles_labels()
# Default order is the order in which the data was plotted
handles = reversed(handles) # Reverse order of legend elements
labels = reversed(labels)

plt.legend(handles,
labels,
loc='center right',
frameon=False,
fontsize=14,
labelspacing=1)
labelspacing=1,
reverse=True)

plt.show()

0 comments on commit 1431c48

Please sign in to comment.