Class: Rust::Plots::ScatterPlot

Inherits:
BasePlot show all
Defined in:
lib/rust/plots/basic-plots.rb

Overview

Allows to create one or many scatter plots.

Instance Method Summary collapse

Methods inherited from BasePlot

#[]=, #_add_renderable, #_do_not_override_options!, #axis, #color, #grid, #palette, #pdf, #show, #title, #x_label, #x_range, #y_label, #y_range

Constructor Details

#initialize(x = nil, y = nil, **options) ⇒ ScatterPlot

Creates a new scatter plot, given two arrays of values x and y for the respective axes (optional). options can be specified and directly passed to the plot function in R.



14
15
16
17
18
19
20
# File 'lib/rust/plots/basic-plots.rb', line 14

def initialize(x = nil, y = nil, **options)
    super()
    @series = []
    if x && y
        self.series(x, y, **options)
    end
end

Instance Method Details

#linesObject

Changes the plot type to lines.



44
45
46
47
48
# File 'lib/rust/plots/basic-plots.rb', line 44

def lines()
    self['type'] = "l"
    
    return self
end

#lines_and_pointsObject

Changes the plot type to lines and points.



62
63
64
65
66
# File 'lib/rust/plots/basic-plots.rb', line 62

def lines_and_points()
    self['type'] = "b"
    
    return self
end

#pointsObject

Changes the plot type to points.



53
54
55
56
57
# File 'lib/rust/plots/basic-plots.rb', line 53

def points()
    self['type'] = "p"
    
    return self
end

#series(x, y, **options) ⇒ Object

Adds a new data series, given the values for the x and y axes. options can be specified and directly passed to the plot function in R.



26
27
28
29
30
# File 'lib/rust/plots/basic-plots.rb', line 26

def series(x, y, **options)
    @series << [x, y, options]
    
    return self
end

#thickness(t) ⇒ Object

Sets the thickness of the plot lines.



35
36
37
38
39
# File 'lib/rust/plots/basic-plots.rb', line 35

def thickness(t)
    self['lwd'] = t
    
    return self
end