Skip to content

ColorbarBase draws edges in slightly wrong positions.  #4584

Closed
@rlabbe

Description

@rlabbe

The code below uses ColorbarBase to print a stacked bar chart of a list of numbers. I use drawedges=True to get vertical lines to separate the colors with a black line. The lines are often, not always, slightly misaligned compared to the colors and the tick marks, never more than a few pixels. As I drag the matplotlib window larger and slower you can see these edge lines sometimes rendering correctly (right where the colors change) or just a few pixels off. I think the error is always to the right.

I've attached an example image. If you click the image to see if full scale you'll see a several pixel error at 0.3, and perhaps a 1 pixel error at 0.4. If I drag the window to a different size I can make these errors larger or smaller.

Environment:
Windows 7
Anaconda Python 3.4, 64 bit installation.
matplotlib 1.4.3
Qt graphics back end

    import matplotlib as mpl
    import matplotlib.pyplot as plt

    a = [.0, .1, .3, .4, 1.]
    cmap = mpl.colors.ListedColormap([[0., .4, 1.],
                                      [0., .8, 1.],
                                      [1., .8, 0.],
                                      [1., .4, 0.],
                                      [0., .4, 1.]])
    fig = plt.figure(figsize=(6,3))
    ax = fig.add_axes([0.05, 0.475, 0.9, 0.15])
    norm = mpl.colors.BoundaryNorm(a, cmap.N)
    mpl.colorbar.ColorbarBase(ax, cmap=cmap,
                                  norm=norm,
                                  drawedges=True,
                                  spacing='proportional',
                                  orientation='horizontal')
    plt.show()

figure_3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions