Skip to content

Commit ffdda1d

Browse files
committed
FIX: Remove square brackets from np.arange in set_ticks calls
The set_ticks() method expects a 1D array with shape (N,), but wrapping np.arange() in square brackets creates a list containing an array with shape (1, N). This fixes the ValueError by passing the array directly.
1 parent 25b18b0 commit ffdda1d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

galleries/users_explain/colors/colormapnorms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@
305305
ax1.set_aspect(1 / np.cos(np.deg2rad(49)))
306306
ax1.set_title('Default: Scaled colorbar')
307307
cb1 = fig.colorbar(pcm1, ax=ax1, shrink=0.6)
308-
cb1.set_ticks([np.arange(-500, 4001, 500)])
308+
cb1.set_ticks(np.arange(-500, 4001, 500))
309309

310310
# Right plot: Linear colorbar spacing
311311
pcm2 = ax2.pcolormesh(longitude, latitude, topo, rasterized=True, norm=divnorm,
@@ -314,7 +314,7 @@
314314
ax2.set_title('Linear colorbar spacing')
315315
cb2 = fig.colorbar(pcm2, ax=ax2, shrink=0.6)
316316
cb2.ax.set_yscale('linear') # Set linear scale for colorbar
317-
cb2.set_ticks([np.arange(-500, 4001, 500)])
317+
cb2.set_ticks(np.arange(-500, 4001, 500))
318318

319319
plt.show()
320320

@@ -383,3 +383,4 @@ def inverse(self, value):
383383
cb.set_ticks([-500, 0, 1000, 2000, 3000, 4000])
384384

385385
plt.show()
386+

0 commit comments

Comments
 (0)