Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Incorrect log y-scale for histogram with partitioned and barstacked data #18457

Copy link
Copy link
Closed
@DuncanSmith147

Description

@DuncanSmith147
Issue body actions

Bug report

Bug summary

When I display 2 datasets on a barstacked histogram with a logged y-scale the lower limit on the y-axis is 10**0 == 1, so not displaying frequencies of 1. Pooling the data results in a histogram with adjusted lower limit so that frequencies of 1 are shown.

Code for reproduction

>>> import random
>>> test_data = [random.random() for _ in range(10)]
>>> import pylab
>>> pylab.hist(test_data, histtype='barstacked')
(array([3., 0., 1., 0., 2., 0., 1., 1., 0., 2.]), array([0.01724381, 0.11487901, 0.21251422, 0.31014942, 0.40778463,
       0.50541983, 0.60305504, 0.70069024, 0.79832545, 0.89596065,
       0.99359586]), <a list of 10 Patch objects>)
>>> pylab.yscale('log')
>>> pylab.savefig('/home/duncan/Documents/test1.jpeg', format='jpeg', dpi=300)
>>> pylab.close()
>>> pylab.hist([test_data[:5], test_data[5:]], histtype='barstacked')
([array([2., 0., 1., 0., 1., 0., 0., 1., 0., 0.]), array([3., 0., 1., 0., 2., 0., 1., 1., 0., 2.])], array([0.01724381, 0.11487901, 0.21251422, 0.31014942, 0.40778463,
       0.50541983, 0.60305504, 0.70069024, 0.79832545, 0.89596065,
       0.99359586]), <a list of 2 Lists of Patches objects>)
>>> pylab.yscale('log')
>>> pylab.savefig('/home/duncan/Documents/test2.jpeg', format='jpeg', dpi=300)
>>> pylab.close()

Actual outcome

# If applicable, paste the console output here
#
#

Expected outcome

Distinct plots with identical y-scales - showing frequencies of 1
test2
test1

Matplotlib version

  • Operating system: Ubuntu 18.04
  • Matplotlib version: 2.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: Python 3.6.9 (default, Jul 17 2020, 12:50:27)
  • Jupyter version (if applicable):
  • Other libraries:

Ubuntu repos

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.