Sha256: 7355b85a028c1493816dd96f10f7c92142f9d673673035296e0c4200714cbd83

Contents?: true

Size: 751 Bytes

Versions: 15

Compression:

Stored size: 751 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

15 entries across 15 versions & 1 rubygems

Version Path
pycall-0.1.0.alpha.20170711 examples/hist.rb
pycall-0.1.0.alpha.20170502 examples/hist.rb
pycall-0.1.0.alpha.20170426 examples/hist.rb
pycall-0.1.0.alpha.20170419b examples/hist.rb
pycall-0.1.0.alpha.20170419a examples/hist.rb
pycall-0.1.0.alpha.20170419 examples/hist.rb
pycall-0.1.0.alpha.20170403 examples/hist.rb
pycall-0.1.0.alpha.20170329 examples/hist.rb
pycall-0.1.0.alpha.20170317 examples/hist.rb
pycall-0.1.0.alpha.20170311 examples/hist.rb
pycall-0.1.0.alpha.20170309 examples/hist.rb
pycall-0.1.0.alpha.20170308 examples/hist.rb
pycall-0.1.0.alpha.20170307 examples/hist.rb
pycall-0.1.0.alpha.20170302 examples/hist.rb
pycall-0.1.0.alpha.20170226 examples/hist.rb