Skip to content

add_lines misses lines for matplotlib.colorbar.ColorbarBase #12458

@e3reiter

Description

@e3reiter

Bug report

Bug summary

For matplotlib.colorbar.ColorbarBase(...) usage of add_lines(...) may yield missing lines/poorly adjusted lines.

Code for reproduction

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

fig = plt.figure()
ax = fig.add_axes([0.05, 0.8, 0.9, 0.15])
cmap = mpl.cm.cool
norm = mpl.colors.Normalize(vmin=-4, vmax=4)
levels = (-1.0, 1.0, 2.0, 3.0)

cb = mpl.colorbar.ColorbarBase(ax, cmap=cmap, norm=norm)
colors_bg = np.tile(list((1.0, 1.0, 1.0, 1.0)), (len(levels), 1))
cb.add_lines(levels=levels, colors=colors_bg, linewidths=7)

plt.show()

Expected outcome

4 white lines, crossing the colorbar.
Used to work on matplotlib 2.2.3!

Matplotlib version

  • Operating system: Ubuntu 18.04 LTS
  • Matplotlib version: 3.0.0
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.7.0

Miniconda install, fully updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions