Skip to content

Commit 4bd5cb1

Browse files
committed
📝
1 parent 6f2f248 commit 4bd5cb1

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Matplotlib
22

3-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/matplotlib`. To experiment with that code, run `bin/console` for an interactive prompt.
4-
5-
TODO: Delete this and the text above, and describe your gem
3+
This library enables to directly call [matplotlib](https://matplotlib.org/) from Ruby language.
4+
This is built on top of [pycall](https://github.com/mrkn/pycall).
65

76
## Installation
87

@@ -18,11 +17,35 @@ And then execute:
1817

1918
Or install it yourself as:
2019

21-
$ gem install matplotlib
20+
$ gem install --pre matplotlib
2221

2322
## Usage
2423

25-
TODO: Write usage instructions here
24+
### Using pyplot in irb console or standalone scripts
25+
26+
Example usage:
27+
28+
require 'matplotlib/pyplot'
29+
plt = Matplotlib::Pyplot
30+
31+
xs = [*1..100].map {|x| (x - 50) * Math::PI / 100.0 }
32+
ys = xs.map {|x| Math.sin(x) }
33+
34+
plt.plot(xs, ys)
35+
plt.show()
36+
37+
### IRuby integration
38+
39+
`matplotlib/iruby` provides integration between IRuby notebook and matplotlib.
40+
This functionality can be enabled by calling `Matplotlib::IRuby.activate`.
41+
42+
require 'matplotlib/iruby'
43+
Matplotlib::IRuby.activate
44+
45+
`matplotlib/iruby` also loads `matplotlib/pyplot`, so you can use `Matplotlib::Pyplot` module without explicitly requireing `matplotlib/pyplot`.
46+
And this introduces a post execution hook which put figures that are created in a cell just below the execution result of the cell.
47+
48+
See ipynb files in [examples](examples) to see example usages.
2649

2750
## Development
2851

0 commit comments

Comments
 (0)