Sha256: 42bb86395550ef92c9b2a9a6c8783cac468f2f456b1e5e4daef85b920efad871

Contents?: true

Size: 740 Bytes

Versions: 12

Compression:

Stored size: 740 Bytes

Contents

require 'pycall/import'
include PyCall::Import

pyimport 'numpy', as: 'np'

# FIXME: MacOSX backend is not usable through pycall.  I want to fix this issue but the reason is unclear.
pyimport 'matplotlib', as: :mp
mp.rcParams[:backend] = 'TkAgg' if mp.rcParams[:backend] == 'MacOSX'

pyimport 'matplotlib.mlab', as: 'mlab'
pyimport 'matplotlib.pyplot', as: 'plt'

np.random.seed(0)

mu = 100
sigma = 15
x = mu + sigma * np.random.randn(437)

num_bins = 50

fig, ax = *plt.subplots

n, bins, patches = *ax.hist(x, num_bins, normed: 1)

y = mlab.normpdf(bins, mu, sigma)
ax.plot(bins, y, '--')
ax.set_xlabel('Smarts')
ax.set_ylabel('Probability density')
ax.set_title('Histogram of IQ: $\mu=100$, $\sigma=15$')

fig.tight_layout()
plt.show()

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pycall-1.2.1 examples/hist.rb
pycall-1.2.0 examples/hist.rb
pycall-1.2.0.beta1 examples/hist.rb
pycall-1.1.0.rc1 examples/hist.rb
pycall-1.0.3 examples/hist.rb
pycall-1.0.2-x86-mingw32 examples/hist.rb
pycall-1.0.2-x64-mingw32 examples/hist.rb
pycall-1.0.2 examples/hist.rb
pycall-1.0.1-x86-mingw32 examples/hist.rb
pycall-1.0.1-x64-mingw32 examples/hist.rb
pycall-1.0.1 examples/hist.rb
pycall-1.0.0 examples/hist.rb