Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Behavior of hist() with normed=True changes from v2.0 to v2.1 #9557

Closed
@jakevdp

Description

@jakevdp

Found in the context of astropy/astropy#6786

When hist() is passed irregular bins with normed=True, the output is different between matplotlib 2.0 and 2.1. Here is a test script to reproduce the issue:

# Python 3.6
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
rng = np.random.RandomState(829)

t = np.concatenate([rng.randn(100),
                    2 + 0.1 * rng.randn(100),
                    5 + 3 * rng.randn(100)])
plt.hist(t, bins=[-5, -3, -2, -1, -0.5, 0, 2, 4, 5, 10], normed=True)
plt.title(f'matplotlib v{matplotlib.__version__}')
plt.savefig(f'hist-{matplotlib.__version__}.png')
plt.show()

hist-2.0.2.png:
hist-2 0 2

hist-2.1.0.png:
hist-2 1 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions