Skip to content

Commit 219e13f

Browse files
committed
Add ColorbarBase.n_rasterize instead of hardwiring the value.
1 parent dbd157d commit 219e13f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/colorbar.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ class ColorbarBase(cm.ScalarMappable):
256256
'min': slice(1, None),
257257
'max': slice(0, -1)}
258258

259+
n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize
260+
259261
def __init__(self, ax, cmap=None,
260262
norm=None,
261263
alpha=None,
@@ -517,7 +519,7 @@ def _add_solids(self, X, Y, C):
517519
colors=(mpl.rcParams['axes.edgecolor'],),
518520
linewidths=linewidths)
519521
self.ax.add_collection(self.dividers)
520-
elif len(self._y) > 50:
522+
elif len(self._y) >= self.n_rasterize:
521523
self.solids.set_rasterized(True)
522524

523525
def add_lines(self, levels, colors, linewidths, erase=True):

0 commit comments

Comments
 (0)