gnuplotrb 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +192 -0
- data/Rakefile +2 -2
- data/gnuplotrb.gemspec +1 -0
- data/lib/gnuplotrb.rb +2 -0
- data/lib/gnuplotrb/animation.rb +1 -1
- data/lib/gnuplotrb/external_classes/dir.rb +9 -0
- data/lib/gnuplotrb/mixins/plottable.rb +2 -2
- data/lib/gnuplotrb/plot.rb +5 -0
- data/lib/gnuplotrb/staff/datablock.rb +1 -1
- data/lib/gnuplotrb/version.rb +1 -1
- metadata +19 -5
- data/README.rdoc +0 -165
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 643e2bfa1bef7121c15e59b7d584b45838d6af60
|
4
|
+
data.tar.gz: 2bcaf62c034347d7fa4db8fe3dae25f416a30a4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0f38c9fa08b336b5b4173318f849adefa3553a940d011b346cfe4140f4d4e7b3bca91dc2a82d0d491226dda2bb4c8f28889d1c47d7e515d5590b4927024f1d1
|
7
|
+
data.tar.gz: 0f831611a7feb81742ee91703702eeed9291696a30b03128ecff4551628b92a49927c936c4ddd20be675422eb6bf2ed53a408a1701c691749cda75cdb6ef77b7
|
data/README.md
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# GnuplotRB
|
2
|
+
GnuplotRB is a plot generator for Ruby based on
|
3
|
+
[Gnuplot](http://www.gnuplot.info).
|
4
|
+
|
5
|
+
This software has been developed as a product in Google Summer of Code 2015 (GSoC2015). Its progress may be saw in [SciRuby mailing list](https://groups.google.com/forum/?fromgroups#!topic/sciruby-dev/lhWvb5hWc3k) or in [project's blog](http://www.evgrafov.work/gnuplotrb/).
|
6
|
+
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/gnuplotrb.svg)](https://badge.fury.io/rb/gnuplotrb)
|
8
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/SciRuby/gnuplotrb.svg)](https://gemnasium.com/github.com/SciRuby/gnuplotrb)
|
9
|
+
[![Build Status](https://travis-ci.org/SciRuby/gnuplotrb.svg?branch=master)](https://travis-ci.org/SciRuby/gnuplotrb)
|
10
|
+
[![Code Climate](https://codeclimate.com/github/SciRuby/gnuplotrb/badges/gpa.svg)](https://codeclimate.com/github/SciRuby/gnuplotrb)
|
11
|
+
[![Test Coverage](https://codeclimate.com/github/SciRuby/gnuplotrb/badges/coverage.svg)](https://codeclimate.com/github/SciRuby/gnuplotrb/coverage)
|
12
|
+
|
13
|
+
## Table of contents
|
14
|
+
* [Installation](https://github.com/sciruby/gnuplotrb#installation)
|
15
|
+
* [Getting started](https://github.com/sciruby/gnuplotrb#getting-started)
|
16
|
+
- [Plottable classes](https://github.com/sciruby/gnuplotrb#plottable-classes)
|
17
|
+
- [Notebooks](https://github.com/sciruby/gnuplotrb#notebooks)
|
18
|
+
- [Plain examples](https://github.com/sciruby/gnuplotrb#plain-examples)
|
19
|
+
* [Contributing](https://github.com/sciruby/gnuplotrb#contributing)
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
### Dependencies
|
23
|
+
* Ruby 2.0+
|
24
|
+
* It is required to install [gnuplot 5.0](http://www.gnuplot.info/download.html) to use that gem.
|
25
|
+
|
26
|
+
### Gem installation
|
27
|
+
#### Install latest stable version from Rubygems
|
28
|
+
|
29
|
+
```sh
|
30
|
+
gem install gnuplotrb
|
31
|
+
```
|
32
|
+
|
33
|
+
#### Install latest stable version using bundler
|
34
|
+
* add `gem gnuplotrb` to your `Gemfile`
|
35
|
+
* run `bundle install`
|
36
|
+
|
37
|
+
#### Install latest version from source (may be unstable)
|
38
|
+
|
39
|
+
```sh
|
40
|
+
git clone https://github.com/sciruby/gnuplotrb.git
|
41
|
+
cd gnuplotrb
|
42
|
+
bundle install
|
43
|
+
rake install
|
44
|
+
```
|
45
|
+
|
46
|
+
## Getting started
|
47
|
+
GnuplotRB gem is based on [Gnuplot](http://www.gnuplot.info/) so I would recommend to use [Gnuplot doc](http://www.gnuplot.info/docs_5.0/gnuplot.pdf) and [GnuplotRB doc at Rubydoc](https://rubygems.org/gems/gnuplotrb) in cases when docs and examples (as notebooks and plain examples) present here are not enough to explain how to plot something.
|
48
|
+
|
49
|
+
### Plottable classes
|
50
|
+
Each of plottable classes may be outputted to image file using ```#to_png```, ```#to_svg```, ```#to_gif``` and so on methods. You can read more about it in [GnuplotRB doc](https://rubygems.org/gems/gnuplotrb) related to Plottable module or see examples in [beginners
|
51
|
+
notebook](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/basic_usage.ipynb).
|
52
|
+
|
53
|
+
#### Dataset
|
54
|
+
Single dataset may be created with math formula ('sin(x)') or some data. If your data is stored in a file you can just pass a filename (e.g. 'gnuplotrb.data'). Dataset may also be constructed out of data contained in Ruby classes (Array, Daru containers), see [example notebooks](https://github.com/sciruby/gnuplotrb#possible-datasources).
|
55
|
+
|
56
|
+
Dataset have several possible options which are explained in [gnuplot
|
57
|
+
doc](http://www.gnuplot.info/docs_5.0/gnuplot.pdf) (pp. 80-102). Options are passed to Dataset.new as hash and are tranlated into gnuplot format before plotting:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
Dataset.new(data, with: 'lines', using: '1:2')
|
61
|
+
```
|
62
|
+
|
63
|
+
Examples of option translation (nested containers allowed):
|
64
|
+
|
65
|
+
* Hash:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
{ key1: "value1", key2: { nested_key1: "nested_value1" } } # => "key1 value1 key2 nested key1 nested_value1"
|
69
|
+
```
|
70
|
+
|
71
|
+
* Hashes with underscored keys (see [#7](https://github.com/dilcom/gnuplotrb/issues/7)):
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
{ style_data: 'histograms' } #=> "style data histograms"
|
75
|
+
```
|
76
|
+
|
77
|
+
* Range:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
{ xrange: 0..100 } # => "xrange [0:100]"
|
81
|
+
```
|
82
|
+
|
83
|
+
* Array (often used with nested hashes) and Array of Numeric
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
['png', { size: [400, 500] }] # => "png size 400,500"
|
87
|
+
```
|
88
|
+
|
89
|
+
* Others
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
some_object # => some_object.to_s
|
93
|
+
```
|
94
|
+
|
95
|
+
Once Dataset created, it may be updated with new data or options. Methods related to updating are explained in [a notebook](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/updating_data.ipynb).
|
96
|
+
|
97
|
+
Just as other Plottable object Dataset has several plotting methods which are desribed in [beginners notebook](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/basic_usage.ipynb).
|
98
|
+
|
99
|
+
#### Plot
|
100
|
+
Plot is a container for several datasets and layout options:
|
101
|
+
```ruby
|
102
|
+
Plot.new(ds1, ds2, ds2, xrange: 1..10)
|
103
|
+
```
|
104
|
+
|
105
|
+
Datasets contained bu Plot are outputted on single xy plain.
|
106
|
+
|
107
|
+
Plot's options are explained in [gnuplot doc](http://www.gnuplot.info/docs_5.0/gnuplot.pdf) (pp. 105-181). Plot options are translated into gnuplot format the same way as Dataset's (except adding 'set' before each option). Plot's datasets and Plot itself may be updated with almost the same methods as desribed in Dataset section above.
|
108
|
+
|
109
|
+
#### Splot
|
110
|
+
Almost the same as Plot but for 3-D plots. See Plot section.
|
111
|
+
|
112
|
+
#### Multiplot
|
113
|
+
|
114
|
+
Container for several Plot or Splot objects, each of them is plotted in its own xy(z) space. So Multiplot offers single layout (image filewindow) for several plots. It's grid is tuned by :layout option, and you can also set layout's title:
|
115
|
+
```ruby
|
116
|
+
Multiplot.new(plot1, plot2, splot1, layout: [3, 1], title: 'Three plots on a layout')
|
117
|
+
```
|
118
|
+
|
119
|
+
Updating methods for Multiplot are almost the same as Plot's and Dataset's and are covered in Multiplot's docs and [multiplot notebook](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/multiplot_layout.ipynb). See examples there.
|
120
|
+
|
121
|
+
#### Animation
|
122
|
+
|
123
|
+
Animation is a container for several Plot, Splot or Multiplot objects. Each of contained items is considered as frame in gif animation which is creating by ```#plot``` call. Animation's frames and options may be modifyed or updated just as other classes above. Animation does not support methods like ```#to_png``` and may be plotted only with ```#plot``` method. Please see [related notebook](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/animated_plots.ipynb) and docs at RubyDoc for examples.
|
124
|
+
|
125
|
+
### Notebooks
|
126
|
+
|
127
|
+
This notebooks are powered by [Ruby kernel](https://github.com/SciRuby/iruby/) for [IPython/Jupyter](https://jupyter.org/). I placed them here to show some GnuplotRB's capabilities and ways of using it together with iRuby.
|
128
|
+
|
129
|
+
To use GnuplotRB gem with iRuby you need to install them both.
|
130
|
+
|
131
|
+
* iRuby installation is covered in its [README](https://github.com/SciRuby/iruby/blob/master/README.md). It also covers installation of iPython and other dependecies.
|
132
|
+
* GnuplotRB gem installation covered in [README](https://github.com/sciruby/gnuplotrb#installation) too.
|
133
|
+
|
134
|
+
|
135
|
+
#### Embedding plots into iRuby
|
136
|
+
Using GnuplotRB inside iRuby notebooks is covered in:
|
137
|
+
|
138
|
+
* [Basic usage notebook](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/basic_usage.ipynb).
|
139
|
+
|
140
|
+
#### 2D and 3D plots
|
141
|
+
GnuplotRB is capable to plot vast range of plots from histograms to 3D
|
142
|
+
heatmaps. Gem's repository contains examples of several plot types:
|
143
|
+
|
144
|
+
* [Heatmaps](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/heatmaps.ipynb)
|
145
|
+
* [Vectorfield](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/vector_field.ipynb) (Thanks, [Alexej](https://github.com/agisga))
|
146
|
+
* [Math equations](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/math_plots.ipynb)
|
147
|
+
* [3D visualizations](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/3d_plot.ipynb)
|
148
|
+
* [Histogram](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/histogram.ipynb)
|
149
|
+
|
150
|
+
|
151
|
+
#### Possible datasources
|
152
|
+
GnuplotRB may take data in Ruby container or in a file. Supported containers
|
153
|
+
for now are `Array`, `Daru::Vector` and `Daru::DataFrame`. When data given in file,
|
154
|
+
GnuplotRB pass filename to Gnuplot **without** reading the file into memory.
|
155
|
+
|
156
|
+
Examples of using different datasources:
|
157
|
+
|
158
|
+
* [Data given in file or Ruby Array](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/points_from_different_sources.ipynb)
|
159
|
+
* [Data given in Daru containers](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/plotting_from_daru.ipynb)
|
160
|
+
* [Data given in Daru containers (with timeseries)](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/time_series_from_daru.ipynb)
|
161
|
+
* [Updating plots with new data](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/updating_data.ipynb)
|
162
|
+
|
163
|
+
|
164
|
+
#### Multiplot
|
165
|
+
You can not only plot several datasets in single coordinate system but place
|
166
|
+
several coordinate systems on a canvas.
|
167
|
+
|
168
|
+
* [Multiplot example notebook](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/multiplot_layout.ipynb).
|
169
|
+
|
170
|
+
#### Animation
|
171
|
+
It's possible to use several plots (Plot, Splot or Multiplot objects) to create gif animation.
|
172
|
+
|
173
|
+
* [Animation example notebook](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/animated_plots.ipynb).
|
174
|
+
|
175
|
+
|
176
|
+
#### Fitting data with formula
|
177
|
+
GnuplotRB also may be used to fit some data with given math formula.
|
178
|
+
|
179
|
+
* [Fitting data](http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/fitting_data.ipynb)
|
180
|
+
|
181
|
+
|
182
|
+
### Plain examples
|
183
|
+
You may find several examples in [examples directory](https://github.com/sciruby/gnuplotrb/tree/master/examples).
|
184
|
+
|
185
|
+
## Contributing
|
186
|
+
|
187
|
+
1. [Fork repository](https://github.com/sciruby/gnuplotrb/fork)
|
188
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
189
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
190
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
191
|
+
5. Create a new Pull Request
|
192
|
+
|
data/Rakefile
CHANGED
@@ -6,11 +6,11 @@ require 'rubocop/rake_task'
|
|
6
6
|
|
7
7
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
8
8
|
spec.pattern = FileList['spec/**/*_spec.rb'].uniq
|
9
|
-
spec.rspec_opts = '--format documentation'
|
9
|
+
spec.rspec_opts = '--format documentation --color'
|
10
10
|
end
|
11
11
|
|
12
12
|
YARD::Rake::YardocTask.new(:doc) do |t|
|
13
|
-
t.files = %w(README.
|
13
|
+
t.files = %w(README.md lib) # optional
|
14
14
|
end
|
15
15
|
|
16
16
|
RuboCop::RakeTask.new(:cop)
|
data/gnuplotrb.gemspec
CHANGED
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'rubocop', '~> 0.29'
|
27
27
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
28
28
|
spec.add_development_dependency 'chunky_png'
|
29
|
+
spec.add_development_dependency 'simplecov'
|
29
30
|
spec.add_development_dependency 'daru'
|
30
31
|
end
|
data/lib/gnuplotrb.rb
CHANGED
@@ -19,6 +19,8 @@ require_if_available('daru')
|
|
19
19
|
require 'gnuplotrb/external_classes/string'
|
20
20
|
require 'gnuplotrb/external_classes/array'
|
21
21
|
require 'gnuplotrb/external_classes/daru'
|
22
|
+
require 'gnuplotrb/external_classes/dir'
|
23
|
+
|
22
24
|
|
23
25
|
require 'gnuplotrb/version'
|
24
26
|
require 'gnuplotrb/staff/settings'
|
data/lib/gnuplotrb/animation.rb
CHANGED
@@ -58,7 +58,7 @@ module GnuplotRB
|
|
58
58
|
plot_opts.merge(term: ['gif', anim_opts])
|
59
59
|
end.to_h
|
60
60
|
need_output = plot_options[:output].nil?
|
61
|
-
plot_options[:output] = Dir
|
61
|
+
plot_options[:output] = Dir.gnuplot_tmpname('anim') if need_output
|
62
62
|
terminal = Terminal.new
|
63
63
|
multiplot(terminal, plot_options)
|
64
64
|
# guaranteed wait for plotting to finish
|
@@ -65,7 +65,7 @@ module GnuplotRB
|
|
65
65
|
# @return [true] for existing methods and
|
66
66
|
# #to_|term_name| when name is a valid terminal type.
|
67
67
|
# @return [false] otherwise
|
68
|
-
def respond_to?(meth_id)
|
68
|
+
def respond_to?(meth_id, include_all=false)
|
69
69
|
# Next line is here to force iRuby use #to_iruby
|
70
70
|
# instead of #to_svg.
|
71
71
|
return super if defined? IRuby
|
@@ -110,7 +110,7 @@ module GnuplotRB
|
|
110
110
|
if path
|
111
111
|
result = plot(term: [terminal, options], output: path)
|
112
112
|
else
|
113
|
-
path = Dir
|
113
|
+
path = Dir.gnuplot_tmpname(terminal)
|
114
114
|
plot(term: [terminal, options], output: path)
|
115
115
|
result = File.binread(path)
|
116
116
|
File.delete(path)
|
data/lib/gnuplotrb/plot.rb
CHANGED
@@ -284,6 +284,7 @@ module GnuplotRB
|
|
284
284
|
when Hamster::Vector
|
285
285
|
datasets[0]
|
286
286
|
when (defined?(Daru) ? Daru::DataFrame : nil)
|
287
|
+
set_name_from_daru_dataframe(datasets[0])
|
287
288
|
Hamster::Vector.new(datasets[0].map { |ds| dataset_from_any(ds) })
|
288
289
|
else
|
289
290
|
Hamster::Vector.new(datasets.map { |ds| dataset_from_any(ds) })
|
@@ -295,5 +296,9 @@ module GnuplotRB
|
|
295
296
|
def new_with_options(options)
|
296
297
|
self.class.new(@datasets, options)
|
297
298
|
end
|
299
|
+
|
300
|
+
def set_name_from_daru_dataframe(dataframe)
|
301
|
+
self.title = dataframe.name unless title
|
302
|
+
end
|
298
303
|
end
|
299
304
|
end
|
@@ -13,7 +13,7 @@ module GnuplotRB
|
|
13
13
|
@stored_in_file = stored_in_file
|
14
14
|
data_str = data.to_gnuplot_points
|
15
15
|
if @stored_in_file
|
16
|
-
@file_name = Dir
|
16
|
+
@file_name = Dir.gnuplot_tmpname('tmp_data')
|
17
17
|
File.write(@file_name, data_str)
|
18
18
|
name = File.join(Dir.pwd, @file_name)
|
19
19
|
ObjectSpace.define_finalizer(self, proc { File.delete(name) })
|
data/lib/gnuplotrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gnuplotrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Evgrafov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hamster
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: daru
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,13 +159,14 @@ extra_rdoc_files: []
|
|
145
159
|
files:
|
146
160
|
- Gemfile
|
147
161
|
- LICENSE
|
148
|
-
- README.
|
162
|
+
- README.md
|
149
163
|
- Rakefile
|
150
164
|
- gnuplotrb.gemspec
|
151
165
|
- lib/gnuplotrb.rb
|
152
166
|
- lib/gnuplotrb/animation.rb
|
153
167
|
- lib/gnuplotrb/external_classes/array.rb
|
154
168
|
- lib/gnuplotrb/external_classes/daru.rb
|
169
|
+
- lib/gnuplotrb/external_classes/dir.rb
|
155
170
|
- lib/gnuplotrb/external_classes/string.rb
|
156
171
|
- lib/gnuplotrb/fit.rb
|
157
172
|
- lib/gnuplotrb/mixins/error_handling.rb
|
@@ -185,9 +200,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
200
|
version: '0'
|
186
201
|
requirements: []
|
187
202
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
203
|
+
rubygems_version: 2.6.13
|
189
204
|
signing_key:
|
190
205
|
specification_version: 4
|
191
206
|
summary: Ruby bindings for gnuplot
|
192
207
|
test_files: []
|
193
|
-
has_rdoc:
|
data/README.rdoc
DELETED
@@ -1,165 +0,0 @@
|
|
1
|
-
= GnuplotRB
|
2
|
-
|
3
|
-
GnuplotRB is a plot generator for Ruby based on {Gnuplot}[http://www.gnuplot.info].
|
4
|
-
|
5
|
-
This software has been developed as a product in Google Summer of Code 2015 (GSoC2015). Its progress may be saw in {SciRuby mailing list}[https://groups.google.com/forum/?fromgroups#!topic/sciruby-dev/lhWvb5hWc3k] or in {project's blog}[http://www.evgrafov.work/gnuplotrb/].
|
6
|
-
|
7
|
-
{<img src="https://badge.fury.io/rb/gnuplotrb.svg" alt="Gem Version" />}[https://rubygems.org/gems/gnuplotrb]
|
8
|
-
|
9
|
-
{<img src="https://gemnasium.com/dilcom/gnuplotrb.svg" alt="Dependency Status" />}[https://gemnasium.com/dilcom/gnuplotrb]
|
10
|
-
|
11
|
-
{<img src="https://travis-ci.org/SciRuby/gnuplotrb.svg" alt="Build Status" />}[https://travis-ci.org/SciRuby/gnuplotrb]
|
12
|
-
|
13
|
-
{<img src="https://codeclimate.com/github/sciruby/gnuplotrb/badges/gpa.svg" alt="Code quality" />}[https://codeclimate.com/github/sciruby/gnuplotrb]
|
14
|
-
|
15
|
-
{<img src="https://codeclimate.com/github/sciruby/gnuplotrb/badges/coverage.svg" alt="Test coverage" />}[https://codeclimate.com/github/sciruby/gnuplotrb]
|
16
|
-
|
17
|
-
== Table of contents
|
18
|
-
* {Installation}[https://github.com/sciruby/gnuplotrb#installation]
|
19
|
-
* {Getting started}[https://github.com/sciruby/gnuplotrb#getting-started]
|
20
|
-
* {Plottable classes}[https://github.com/sciruby/gnuplotrb#plottable-classes]
|
21
|
-
* {Notebooks}[https://github.com/sciruby/gnuplotrb#notebooks]
|
22
|
-
* {Plain examples}[https://github.com/sciruby/gnuplotrb#plain-examples]
|
23
|
-
* {Contributing}[https://github.com/sciruby/gnuplotrb#contributing]
|
24
|
-
|
25
|
-
== Installation
|
26
|
-
=== Dependencies
|
27
|
-
* Ruby 2.0+
|
28
|
-
* It is required to install {gnuplot 5.0}[http://www.gnuplot.info/download.html] to use that gem.
|
29
|
-
=== Gem installation
|
30
|
-
==== Install latest stable version from Rubygems
|
31
|
-
gem install gnuplotrb
|
32
|
-
==== Install latest stable version using bundler
|
33
|
-
* add
|
34
|
-
gem 'gnuplotrb'
|
35
|
-
to your Gemfile
|
36
|
-
* run
|
37
|
-
bundle install
|
38
|
-
==== Install latest version from source (may be unstable)
|
39
|
-
git clone https://github.com/sciruby/gnuplotrb.git
|
40
|
-
cd gnuplotrb
|
41
|
-
bundle install
|
42
|
-
rake install
|
43
|
-
|
44
|
-
== Getting started
|
45
|
-
|
46
|
-
GnuplotRB gem is based on {Gnuplot}[http://www.gnuplot.info/] so I would recommend to use {Gnuplot doc}[http://www.gnuplot.info/docs_5.0/gnuplot.pdf] and {GnuplotRB doc at Rubydoc}[https://rubygems.org/gems/gnuplotrb] in cases when docs and examples (as notebooks and plain examples) present here are not enough to explain how to plot something.
|
47
|
-
|
48
|
-
=== Plottable classes
|
49
|
-
|
50
|
-
Each of plottable classes may be outputted to image file using ```#to_png```, ```#to_svg```, ```#to_gif``` and so on methods. You can read more about it in {GnuplotRB doc}[https://rubygems.org/gems/gnuplotrb] related to Plottable module or see examples in {beginners notebook}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/basic_usage.ipynb].
|
51
|
-
|
52
|
-
==== Dataset
|
53
|
-
Single dataset may be created with math formula ('sin(x)') or some data. If your data is stored in a file you can just pass a filename (e.g. 'gnuplotrb.data'). Dataset may also be constructed out of data contained in Ruby classes (Array, Daru containers), see {example notebooks}[https://github.com/sciruby/gnuplotrb#possible-datasources].
|
54
|
-
|
55
|
-
Dataset have several possible options which are explained in {gnuplot doc}[http://www.gnuplot.info/docs_5.0/gnuplot.pdf] (pp. 80-102). Options are passed to Dataset.new as hash and are tranlated into gnuplot format before plotting:
|
56
|
-
Dataset.new(data, with: 'lines', using: '1:2')
|
57
|
-
Examples of option translation (nested containers allowed):
|
58
|
-
* Hash:
|
59
|
-
{ key1: "value1", key2: { nested_key1: "nested_value1" } }
|
60
|
-
# =>
|
61
|
-
"key1 value1 key2 nested key1 nested_value1"
|
62
|
-
* Hashes with underscored keys (see {#7}[https://github.com/dilcom/gnuplotrb/issues/7]):
|
63
|
-
{ style_data: 'histograms' }
|
64
|
-
#=>
|
65
|
-
"style data histograms"
|
66
|
-
* Range:
|
67
|
-
{ xrange: 0..100 }
|
68
|
-
# =>
|
69
|
-
"xrange [0:100]"
|
70
|
-
* Array (often used with nested hashes) and Array of Numeric
|
71
|
-
['png', { size: [400, 500] }]
|
72
|
-
# =>
|
73
|
-
"png size 400,500"
|
74
|
-
* Others
|
75
|
-
some_object
|
76
|
-
# =>
|
77
|
-
some_object.to_s
|
78
|
-
|
79
|
-
Once Dataset created, it may be updated with new data or options. Methods related to updating are explained in {a notebook}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/updating_data.ipynb].
|
80
|
-
|
81
|
-
Just as other Plottable object Dataset has several plotting methods which are desribed in {beginners notebook}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/basic_usage.ipynb].
|
82
|
-
|
83
|
-
==== Plot
|
84
|
-
Plot is a container for several datasets and layout options:
|
85
|
-
Plot.new(ds1, ds2, ds2, xrange: 1..10)
|
86
|
-
|
87
|
-
Datasets contained bu Plot are outputted on single xy plain.
|
88
|
-
|
89
|
-
Plot's options are explained in {gnuplot doc}[http://www.gnuplot.info/docs_5.0/gnuplot.pdf] (pp. 105-181). Plot options are translated into gnuplot format the same way as Dataset's (except adding 'set' before each option). Plot's datasets and Plot itself may be updated with almost the same methods as desribed in Dataset section above.
|
90
|
-
|
91
|
-
==== Splot
|
92
|
-
Almost the same as Plot but for 3-D plots. See Plot section.
|
93
|
-
|
94
|
-
==== Multiplot
|
95
|
-
|
96
|
-
Container for several Plot or Splot objects, each of them is plotted in its own xy(z) space. So Multiplot offers single layout (image file\window) for several plots. It's grid is tuned by :layout option, and you can also set layout's title:
|
97
|
-
Multiplot.new(plot1, plot2, splot1, layout: [3, 1], title: 'Three plots on a layout')
|
98
|
-
|
99
|
-
Updating methods for Multiplot are almost the same as Plot's and Dataset's and are covered in Multiplot's docs and {multiplot notebook}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/multiplot_layout.ipynb]. See examples there.
|
100
|
-
|
101
|
-
==== Animation
|
102
|
-
|
103
|
-
Animation is a container for several Plot, Splot or Multiplot objects. Each of contained items is considered as frame in gif animation which is creating by ```#plot``` call. Animation's frames and options may be modifyed or updated just as other classes above. Animation does not support methods like ```#to_png``` and may be plotted only with ```#plot``` method. Please see {related notebook}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/animated_plots.ipynb] and docs at RubyDoc for examples.
|
104
|
-
|
105
|
-
=== Notebooks
|
106
|
-
|
107
|
-
This notebooks are powered by {Ruby kernel}[https://github.com/SciRuby/iruby/] for {IPython/Jupyter}[https://jupyter.org/].
|
108
|
-
I placed them here to show some GnuplotRB's capabilities and ways of using it together with iRuby.
|
109
|
-
|
110
|
-
To use GnuplotRB gem with iRuby you need to install them both.
|
111
|
-
|
112
|
-
* iRuby installation is covered in its {README}[https://github.com/SciRuby/iruby/blob/master/README.md].
|
113
|
-
It also covers installation of iPython and other dependecies.
|
114
|
-
* GnuplotRB gem installation covered in {README}[https://github.com/sciruby/gnuplotrb#installation] too.
|
115
|
-
|
116
|
-
==== Embedding plots into iRuby
|
117
|
-
Using GnuplotRB inside iRuby notebooks is covered in:
|
118
|
-
|
119
|
-
* {Basic usage notebook}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/basic_usage.ipynb].
|
120
|
-
|
121
|
-
==== 2D and 3D plots
|
122
|
-
GnuplotRB is capable to plot vast range of plots from histograms to 3D heatmaps. Gem's repository contains examples of several plot types:
|
123
|
-
|
124
|
-
* {Heatmaps}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/heatmaps.ipynb]
|
125
|
-
* {Vector field}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/vector_field.ipynb] (Thanks, {Alexej}[https://github.com/agisga])
|
126
|
-
* {Math equations}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/math_plots.ipynb]
|
127
|
-
* {3D visualizations}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/3d_plot.ipynb]
|
128
|
-
* {Histogram}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/histogram.ipynb]
|
129
|
-
|
130
|
-
==== Possible datasources
|
131
|
-
GnuplotRB may take data in Ruby container or in a file. Supported containers for now are Arrays, Daru::Vector and Daru::DataFrame.
|
132
|
-
When data given in file, GnuplotRB pass filename to Gnuplot *without* reading the file into memory.
|
133
|
-
|
134
|
-
Examples of using different datasources:
|
135
|
-
|
136
|
-
* {Data given in file or Ruby Array}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/points_from_different_sources.ipynb]
|
137
|
-
* {Data given in Daru containers}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/plotting_from_daru.ipynb]
|
138
|
-
* {Data given in Daru containers (with timeseries)}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/time_series_from_daru.ipynb]
|
139
|
-
* {Updating plots with new data}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/updating_data.ipynb]
|
140
|
-
|
141
|
-
==== Multiplot
|
142
|
-
You can not only plot several datasets in single coordinate system but place several coordinate systems on a canvas.
|
143
|
-
|
144
|
-
* {Multiplot example notebook}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/multiplot_layout.ipynb].
|
145
|
-
|
146
|
-
==== Animation
|
147
|
-
It's possible to use several plots (Plot, Splot or Multiplot objects) to create gif animation.
|
148
|
-
|
149
|
-
* {Animation example notebook}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/animated_plots.ipynb].
|
150
|
-
|
151
|
-
==== Fitting data with formula
|
152
|
-
GnuplotRB also may be used to fit some data with given math formula.
|
153
|
-
|
154
|
-
* {Fitting data}[http://nbviewer.ipython.org/github/sciruby/gnuplotrb/blob/master/notebooks/fitting_data.ipynb]
|
155
|
-
|
156
|
-
=== Plain examples
|
157
|
-
You may find several examples in {examples directory}[https://github.com/sciruby/gnuplotrb/tree/master/examples].
|
158
|
-
|
159
|
-
== Contributing
|
160
|
-
|
161
|
-
1. {Fork repository}[https://github.com/sciruby/gnuplotrb/fork]
|
162
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
163
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
164
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
165
|
-
5. Create a new Pull Request
|