FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Histogram missing in Matplotlib 2.1.0 · Issue #9628 · matplotlib/matplotlib · GitHub

Repository navigation

Histogram missing in Matplotlib 2.1.0 #9628

Closed

Description

Bug report

Bug summary

Histogram missing in Matplotlib 2.1.0. See the following figures, one is from 2.1.0 and the other is from 2.0.2.

Code for reproduction

This code is exactly the same code we are using except the data is changed to random one. I suppose it will be minimal enough?

#!/usr/bin/env python3

import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import collections

def plot_figure(distribution):
    percentile = [95, 99]
    percentile_color = 'yg'
    mean_color = 'c'
    bins = 100

    legend_handle = []
    legend_title = []

    fig, (ax0, ax1) = plt.subplots(2, sharex=True)
    fig.subplots_adjust(hspace=0)
    mu, sigma = 100, 15
    xs_downstream = mu + sigma*np.random.randn(10000)
    xs_upstream = mu + sigma*np.random.randn(10000)
    xmin = min(np.min(xs_downstream), np.min(xs_upstream))
    xmax = max(np.max(xs_downstream), np.max(xs_upstream))

    hist0 = ax0.hist(xs_downstream, bins=bins, range=(xmin, xmax), color='red', label='{} workload with Proxy'.format(distribution.capitalize()))
    handles, labels = ax0.get_legend_handles_labels()
    line = ax0.axvline(x=np.mean(xs_downstream), color=mean_color, linewidth=1)
    legend_title.append('Mean')
    legend_handle.append(line)

    for percent, color in zip(percentile, percentile_color):
        line = ax0.axvline(x=xs_downstream[int(percent / 100 * len(xs_downstream))], color=color, linewidth=1)
        legend_title.append('{}th percentile'.format(percent))
        legend_handle.append(line)

    ax0.set_yscale('log')
    legend_title += labels
    legend_handle += handles

    hist1 = ax1.hist(xs_upstream, bins=bins, range=(xmin, xmax), color='blue', label='{} workload without Proxy'.format(distribution.capitalize()))
    handles, labels = ax1.get_legend_handles_labels()
    legend_title += labels
    legend_handle += handles
    ax1.axvline(x=np.mean(xs_upstream), color=mean_color, linewidth=1)

    for percent, color in zip(percentile, percentile_color):
        ax1.axvline(x=xs_upstream[int(percent / 100 * len(xs_upstream))], color=color, linewidth=1)

    ax1.set_yscale('log')
    ax0.legend(legend_handle, legend_title)
    ax1.set_xlabel('latency (ms)')

    fig.savefig('latency-{}.pdf'.format(distribution))

def main():
    plot_figure('zipf')
    plot_figure('uniform')

if __name__ == '__main__':
    main()

Actual outcome

Expected outcome

Works well in 2.0.2.

Matplotlib version

  • Operating system: Both macOS High Sierra and Ubuntu 17.10
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX
  • Python version: 3.6.3
  • Jupyter version (if applicable):
  • Other libraries:

Installed using pip3

Thanks!

Activity

  1. added this to the v2.1.1 milestone on Oct 30, 2017
  2. tacaswell commented on Oct 30, 2017

    Member

    This is a duplicate of #9288 both of which were fixed by #9477 which will be include in 2.1.1 which will be out 'soon'.

    In the mean time passing ax0.set_yscale('log', nonposy='clip') is a functional work around.

  3. tacaswell commented on Oct 30, 2017

    Member

    Sorry we broke this and thank you for taking the time to report it with clear example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL