[deprecations] replace scipy.hist with np function ...
and deprecation of normed keyword in nphistogram
This commit is contained in:
parent
5be1c25187
commit
8ab483d3a8
@ -52,7 +52,7 @@ def get_binned_rate(times, bin_width=0.05, max_t=30., dt=1e-4):
|
||||
time = np.arange(0., max_t, dt)
|
||||
bins = np.arange(0., max_t, bin_width)
|
||||
bin_indices = np.asarray(bins / dt, np.int)
|
||||
hist, _ = sp.histogram(times, bins)
|
||||
hist, _ = np.histogram(times, bins)
|
||||
rate = np.zeros(time.shape)
|
||||
|
||||
for i, b in enumerate(bin_indices[1:]):
|
||||
|
@ -2,10 +2,11 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from plotstyle import *
|
||||
|
||||
sketch_style()
|
||||
# roll the die:
|
||||
rng = np.random.RandomState(57281)
|
||||
x1 = rng.random_integers(1, 6, 100)
|
||||
x2 = rng.random_integers(1, 6, 500)
|
||||
x1 = rng.randint(1, 7, 100)
|
||||
x2 = rng.randint(1, 7, 500)
|
||||
bins = np.arange(0.5, 7, 1.0)
|
||||
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2)
|
||||
@ -26,5 +27,6 @@ ax2.set_xlabel('x')
|
||||
ax2.set_ylim(0, 0.23)
|
||||
ax2.set_ylabel('Probability')
|
||||
ax2.plot([0.2, 6.8], [1.0/6.0, 1.0/6.0], zorder=-10, **lsAm)
|
||||
ax2.hist([x2, x1], bins, normed=True, zorder=-5, **fs)
|
||||
ax2.hist([x2, x1], bins, density=True, zorder=-5, **fs)
|
||||
fig.subplots_adjust(left=0.125)
|
||||
fig.savefig('diehistograms.pdf')
|
||||
|
@ -4,6 +4,7 @@ import matplotlib.gridspec as gridspec
|
||||
from scipy.stats import gaussian_kde
|
||||
from plotstyle import *
|
||||
|
||||
sketch_style()
|
||||
#rng = np.random.RandomState(981)
|
||||
#data = rng.randn(40, 1) + 4.0
|
||||
rng = np.random.RandomState(1981)
|
||||
@ -90,6 +91,6 @@ bw = 0.75
|
||||
bins = np.arange(0, 8.0+bw, bw)
|
||||
h, b = np.histogram(data, bins)
|
||||
ax.barh(b[:-1], h/bw/np.sum(h), bw, **fsB)
|
||||
|
||||
fig.subplots_adjust(top=0.9, bottom=0.2)
|
||||
plt.savefig('displayunivariatedata.pdf')
|
||||
|
||||
|
@ -44,7 +44,7 @@ ax.set_ylabel('p(x)')
|
||||
ax.set_ylim(0.0, 0.49)
|
||||
ax.set_yticks(np.arange(0.0, 0.41, 0.1))
|
||||
#ax.plot(x, g, '-b', lw=2, zorder=-1)
|
||||
ax.hist(r, np.arange(-4.1, 4, 0.4), normed=True, zorder=-5, **fsC)
|
||||
ax.hist(r, np.arange(-4.1, 4, 0.4), density=True, zorder=-5, **fsC)
|
||||
|
||||
ax = fig.add_subplot(spec[1, 0])
|
||||
ax.set_xlabel('x')
|
||||
@ -54,7 +54,7 @@ ax.set_ylabel('p(x)')
|
||||
ax.set_ylim(0.0, 0.49)
|
||||
ax.set_yticks(np.arange(0.0, 0.41, 0.1))
|
||||
#ax.plot(x, g, '-b', lw=2, zorder=-1)
|
||||
ax.hist(r, np.arange(-4.3, 4, 0.4), normed=True, zorder=-5, **fsC)
|
||||
ax.hist(r, np.arange(-4.3, 4, 0.4), density=True, zorder=-5, **fsC)
|
||||
|
||||
ax = fig.add_subplot(spec[:, 1])
|
||||
ax.set_xlabel('x')
|
||||
@ -66,6 +66,6 @@ ax.set_yticks(np.arange(0.0, 0.41, 0.1))
|
||||
kd, xx = kerneldensity(r, -3.2, 3.2, 0.2)
|
||||
ax.fill_between(xx, 0.0, kd, zorder=-5, **fsDs)
|
||||
ax.plot(xx, kd, '-', zorder=-1, **lsB)
|
||||
|
||||
fig.subplots_adjust(left=0.15)
|
||||
fig.savefig('kerneldensity.pdf')
|
||||
|
||||
|
@ -24,8 +24,8 @@ ax2.set_ylabel('Probab. density p(x)')
|
||||
ax2.set_ylim(0.0, 0.44)
|
||||
ax2.set_yticks(np.arange(0.0, 0.41, 0.1))
|
||||
ax2.plot(x, g, zorder=-1, **lsA)
|
||||
ax2.hist(r, 5, normed=True, zorder=-10, **fsB)
|
||||
ax2.hist(r, 20, normed=True, zorder=-5, **fsC)
|
||||
ax2.hist(r, 5, density=True, zorder=-10, **fsB)
|
||||
ax2.hist(r, 20, density=True, zorder=-5, **fsC)
|
||||
|
||||
fig.savefig('pdfhistogram.pdf')
|
||||
|
||||
|
Reference in New Issue
Block a user