Skip to content

colorbar labelling bug (1.5 regression) #5673

@jswhit

Description

@jswhit

This is 1.5 regression, the following test script works in 1.4.3.

The bug only occurs when using a custom colormap.

import matplotlib.pyplot as plt
import numpy as np
from matplotlib import mlab, cm, colors
# make up fake data.
delta = 0.5
x = np.arange(-3.0, 4.001, delta)
y = np.arange(-4.0, 3.001, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = (Z1 - Z2) * 20000 ; Z -= Z.min(); Z *= 0.5
# levels to contour
clevs = [0,2,5,10,20,50,100,300,500,700,1000,1500,2000,2500,3000,3500]
# contour data, make colorbar
fig = plt.figure(figsize=(9.,6.3))
colorst =\
['White','#E4FFFF','#C4E8FF','#8FB3FF','#D8F9D8','#A6ECA6','#42F742','Yellow','Gold',\
 'Orange','#FCD5D9','#F6A3AE','#FA5257','Orchid','#AD8ADB','#A449FF','LightGray']
custom_cm = colors.ListedColormap(colorst, name='colorst', N=None)
ax = fig.add_axes([0.03,.12,0.94,.83])
cs = plt.contourf(X, Y, Z, clevs, colors=colorst)
cax = fig.add_axes([0.1,0.05,0.8,0.03])
cbar = fig.colorbar(cs,extend='neither', \
      orientation='horizontal',cax=cax,drawedges=True,ticks=clevs)
plt.show()

The resulting image

colorbar_bug

does not show all the colorbar labels.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions