Skip to content

Commit

Permalink
Backport PR matplotlib#29036: Don't pass redundant inline=True to exa…
Browse files Browse the repository at this point in the history
…mple clabel() calls.
  • Loading branch information
timhoffm authored and meeseeksmachine committed Oct 29, 2024
1 parent 981e635 commit 9b1b45b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions galleries/examples/images_contours_and_fields/contour_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

fig, ax = plt.subplots()
CS = ax.contour(X, Y, Z)
ax.clabel(CS, inline=True, fontsize=10)
ax.clabel(CS, fontsize=10)
ax.set_title('Simplest default with labels')

# %%
Expand All @@ -42,15 +42,15 @@
CS = ax.contour(X, Y, Z)
manual_locations = [
(-1, -1.4), (-0.62, -0.7), (-2, 0.5), (1.7, 1.2), (2.0, 1.4), (2.4, 1.7)]
ax.clabel(CS, inline=True, fontsize=10, manual=manual_locations)
ax.clabel(CS, fontsize=10, manual=manual_locations)
ax.set_title('labels at selected locations')

# %%
# You can force all the contours to be the same color.

fig, ax = plt.subplots()
CS = ax.contour(X, Y, Z, 6, colors='k') # Negative contours default to dashed.
ax.clabel(CS, fontsize=9, inline=True)
ax.clabel(CS, fontsize=9)
ax.set_title('Single color - negative contours dashed')

# %%
Expand All @@ -59,7 +59,7 @@
plt.rcParams['contour.negative_linestyle'] = 'solid'
fig, ax = plt.subplots()
CS = ax.contour(X, Y, Z, 6, colors='k') # Negative contours default to dashed.
ax.clabel(CS, fontsize=9, inline=True)
ax.clabel(CS, fontsize=9)
ax.set_title('Single color - negative contours solid')

# %%
Expand All @@ -70,7 +70,7 @@
linewidths=np.arange(.5, 4, .5),
colors=('r', 'green', 'blue', (1, 1, 0), '#afeeee', '0.5'),
)
ax.clabel(CS, fontsize=9, inline=True)
ax.clabel(CS, fontsize=9)
ax.set_title('Crazy lines')

# %%
Expand All @@ -90,7 +90,7 @@
CS.set_linewidth(lws)

ax.clabel(CS, levels[1::2], # label every second level
inline=True, fmt='%1.1f', fontsize=14)
fmt='%1.1f', fontsize=14)

# make a colorbar for the contour lines
CB = fig.colorbar(CS, shrink=0.8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def fmt(x):
fig, ax = plt.subplots()
CS = ax.contour(X, Y, Z)

ax.clabel(CS, CS.levels, inline=True, fmt=fmt, fontsize=10)
ax.clabel(CS, CS.levels, fmt=fmt, fontsize=10)

# %%
# Label contours with arbitrary strings using a dictionary
Expand All @@ -59,7 +59,7 @@ def fmt(x):
fmt[l] = s

# Label every other level using strings
ax1.clabel(CS1, CS1.levels[::2], inline=True, fmt=fmt, fontsize=10)
ax1.clabel(CS1, CS1.levels[::2], fmt=fmt, fontsize=10)

# %%
# Use a Formatter
Expand Down
1 change: 0 additions & 1 deletion galleries/examples/misc/demo_agg_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def filtered_text(ax):

# contour label
cl = ax.clabel(CS, levels[1::2], # label every second level
inline=True,
fmt='%1.1f',
fontsize=11)

Expand Down

0 comments on commit 9b1b45b

Please sign in to comment.