Skip to content

colorbar labelling bug (1.5 regression) #5673

Closed

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.

Activity

  1. mdboom commented on Dec 14, 2015

    @mdboom
    Member

    First bad commit is ba7bc0a. @efiring: Any immediate thoughts?

  2. self-assigned this
    on Dec 14, 2015
  3. efiring commented on Dec 14, 2015

    @efiring
    Member

    I'm starting to get an inkling. I should be able to sort it out in a day or two. Thanks for bisecting.

  4. added this to the milestone on Dec 14, 2015
  5. added a commit that references this issue on Dec 20, 2015
    b16caa1
  6. added a commit that references this issue on Dec 20, 2015
    497ffa8
  7. added 2 commits that reference this issue on Dec 20, 2015
    f19fea6
    4fd5f55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions