X Tutup
Skip to content

'Extend' keyword produces colorbar of zero width #7686

@AnkitBarik

Description

@AnkitBarik

The 'extend' keyword gives a line instead of a colorbar.

Matplotlib version: 2.0.0rc2+2827.gab98852
Numpy version: 1.13.0.dev0+2498b74
Python version: 2.7.6
Compiler: gcc
Platform: Linux

Installation procedure: from source - using pip as well as directly using setup.py (tried both with same result)

Here's a piece of code generating the following

import matplotlib.pyplot as plt
import numpy as np
import matplotlib.colors as mplc

x, y = np.mgrid[0:1:0.01, 0:1:0.01]
r = np.sqrt(x ** 2 + y ** 2)
z = np.sin(6 * np.pi * r)

norm = mplc.Normalize(0, 0.5)
fig0, ax0 = plt.subplots(1, 1, )
cf0 = ax0.contourf(x, y, z, np.arange(0, .5, .01), norm=norm,
                   extend='both', cmap='viridis')
cbar0 = plt.colorbar(cf0,)

Output:

/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.py:2888: UserWarning: Attempting to set identical left==right results
in singular transformations; automatically expanding.
left=0.5, right=0.5
  'left=%s, right=%s') % (left, right))

figure_1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup