8000 Histogram missing in Matplotlib 2.1.0 · Issue #9628 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Histogram missing in Matplotlib 2.1.0 #9628
Closed
@abcdabcd987

Description

@abcdabcd987

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

qq20171030-095657 2x

Expected outcome

qq20171030-095722 2x

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0