Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rendering bugs in log/log-base-2 histograms #3176

Closed
haberman opened this issue Jul 1, 2014 · 4 comments
Closed

rendering bugs in log/log-base-2 histograms #3176

haberman opened this issue Jul 1, 2014 · 4 comments

Comments

@haberman
Copy link

haberman commented Jul 1, 2014

My attempts to plot log/log-base-2 histograms were unsuccessful:

http://nbviewer.ipython.org/gist/haberman/4c7cc0697ab5c42568f5

Sorry if this is a dup.

@tacaswell
Copy link
Member

Please send this to the mailing list or post in on stackoverflow. Ask to re-open if this you think this is actually a bug.

@haberman
Copy link
Author

haberman commented Jul 1, 2014

It seemed kind of self-evident that the first rendering isn't correct. Does that look like a histogram to you?

The second example in the notebook I linked has been identified as something that used to work but appears to have regressed in 1.3.1: http://stackoverflow.com/questions/16147827/histogram-with-base-2-logarithmic-y-scale-in-matplotlib

@tacaswell
Copy link
Member

It was not clear from the issue that this was a bug-report, not a request for getting help to make code work. Can you also please paste code + images directly into the issue? The link to your notebook will rot eventually.

@tacaswell tacaswell reopened this Jul 2, 2014
@tacaswell
Copy link
Member

Actually, I am going to close this again, both blocks of code work as expected for me on close-to-master:

import random
import numpy
from matplotlib import pyplot, axes
import pylab
import math

pylab.rcParams['figure.figsize'] = (14.0, 8.0)

bins = numpy.logspace(-64, 64, base=2)

def bin_iter(bins):
    for i in range(len(bins) - 1):
        yield (bins[i], bins[i + 1])

x = [long(high - low) for low, high in bin_iter(bins)]
y = [1 for _ in bin_iter(bins)]

fig = pyplot.figure()
plot = fig.add_subplot(111)
plot.set_yscale("log", basey=2)
plot.set_xscale("log", basex=2)
plot.hist(x, bins, alpha=0.6, label='x', cumulative=True, histtype='stepfilled')
plot.legend(loc='upper right')
pyplot.show()

gh1

import numpy as np
import matplotlib.pyplot as plt
mu, sigma = 100, 15
fig, ax = plt.subplots()
x = mu + sigma * np.random.randn(10000)
ax.set_yscale('log', basey=2)
n, bins, histpatches = ax.hist(x, 50, facecolor='green', alpha=0.75)
plt.show()

gh2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants