Skip to content

Commit c2c2976

Browse files
author
Ivan Evgrafov
authoredApr 11, 2017
Merge branch 'master' into fix_taking_name_from_dataframe
2 parents a00c7d2 + 6f11232 commit c2c2976

File tree

6 files changed

+206
-173
lines changed

6 files changed

+206
-173
lines changed
 

‎.travis.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ rvm:
1111
- ruby-2.2.4
1212
- ruby-2.2.2
1313
- ruby-2.3.0-preview2
14-
- jruby-head
1514
matrix:
1615
exclude:
1716
- os: linux
@@ -24,8 +23,12 @@ matrix:
2423
rvm: ruby-2.0.0-p648
2524
- os: osx
2625
rvm: ruby-2.3.0-preview2
27-
env:
28-
- JRUBY_OPTS="-Xcli.debug=true --debug"
26+
include:
27+
- rvm: jruby-head
28+
env: JRUBY_OPTS="-Xcli.debug=true --debug"
29+
addons:
30+
code_climate:
31+
repo_token: 60d9731d654527cb53aabc7db15bcde87d701ddb6b1cba8fc0da6aba16d00bb1
2932
before_install:
3033
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then sudo add-apt-repository "deb http://cz.archive.ubuntu.com/ubuntu vivid main universe" ; fi
3134
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then sudo apt-get update -q ; fi
@@ -41,4 +44,5 @@ install:
4144
- bundle exec rake install
4245
script:
4346
- bundle exec rake spec
44-
- CODECLIMATE_REPO_TOKEN=60d9731d654527cb53aabc7db15bcde87d701ddb6b1cba8fc0da6aba16d00bb1 bundle exec codeclimate-test-reporter
47+
after_success:
48+
- bundle exec codeclimate-test-reporter

‎README.md

+192
Original file line numberDiff line numberDiff line change
@@ -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+

‎README.rdoc

-165
This file was deleted.

‎Rakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ require 'rubocop/rake_task'
66

77
RSpec::Core::RakeTask.new(:spec) do |spec|
88
spec.pattern = FileList['spec/**/*_spec.rb'].uniq
9-
spec.rspec_opts = '--format documentation'
9+
spec.rspec_opts = '--format documentation --color'
1010
end
1111

1212
YARD::Rake::YardocTask.new(:doc) do |t|
13-
t.files = %w(README.rdoc lib) # optional
13+
t.files = %w(README.md lib) # optional
1414
end
1515

1616
RuboCop::RakeTask.new(:cop)

‎lib/gnuplotrb/mixins/plottable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def method_missing(meth_id, *args)
6565
# @return [true] for existing methods and
6666
# #to_|term_name| when name is a valid terminal type.
6767
# @return [false] otherwise
68-
def respond_to?(meth_id)
68+
def respond_to?(meth_id, include_all=false)
6969
# Next line is here to force iRuby use #to_iruby
7070
# instead of #to_svg.
7171
return super if defined? IRuby

‎spec/spec_helper.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
require 'chunky_png'
44
require 'digest/md5'
55

6-
SimpleCov.start
6+
SimpleCov.start do
7+
add_filter 'examples'
8+
end
79

810
require 'gnuplotrb'
911

0 commit comments

Comments
 (0)
Please sign in to comment.