Class: Rust::Plots::BasePlot
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BasePlot.
6
7
8
9
10
|
# File 'lib/rust-plots.rb', line 6
def initialize
@renderables = []
@options = Rust::Options.new
@override_options = true
end
|
Instance Method Details
#[]=(option, value) ⇒ Object
70
71
72
|
# File 'lib/rust-plots.rb', line 70
def []=(option, value)
@options[option.to_s] = value
end
|
#_add_renderable(renderable) ⇒ Object
63
64
65
66
67
68
|
# File 'lib/rust-plots.rb', line 63
def _add_renderable(renderable)
raise TypeError, "Expected Renderable" unless renderable.is_a?(Renderable)
@renderables << renderable
return self
end
|
#_do_not_override_options! ⇒ Object
74
75
76
|
# File 'lib/rust-plots.rb', line 74
def _do_not_override_options!
@override_options = false
end
|
#axis(axis) ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/rust-plots.rb', line 36
def axis(axis)
@options['xaxt'] = 'n'
@options['yaxt'] = 'n'
self._add_renderable(axis)
return self
end
|
#color(color) ⇒ Object
57
58
59
60
61
|
# File 'lib/rust-plots.rb', line 57
def color(color)
@options['col'] = color
return self
end
|
#grid(grid) ⇒ Object
45
46
47
48
49
|
# File 'lib/rust-plots.rb', line 45
def grid(grid)
self._add_renderable(grid)
return self
end
|
#pdf(path, **options) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/rust-plots.rb', line 87
def pdf(path, **options)
pdf_function = Rust::Function.new("pdf")
pdf_function.options = Rust::Options.from_hash(options)
pdf_function.options['file'] = path
Rust.exclusive do
pdf_function.call
self._show
self._render_others
Rust._eval("dev.off()")
end
return self
end
|
78
79
80
81
82
83
84
85
|
# File 'lib/rust-plots.rb', line 78
def show()
Rust.exclusive do
self._show
self._render_others
end
return self
end
|
#title(title) ⇒ Object
51
52
53
54
55
|
# File 'lib/rust-plots.rb', line 51
def title(title)
@options['main'] = title
return self
end
|
#x_label(label) ⇒ Object
12
13
14
15
16
|
# File 'lib/rust-plots.rb', line 12
def x_label(label)
@options['xlab'] = label
return self
end
|
#x_range(range) ⇒ Object
24
25
26
27
28
|
# File 'lib/rust-plots.rb', line 24
def x_range(range)
@options['xlim'] = range
return self
end
|
#y_label(label) ⇒ Object
18
19
20
21
22
|
# File 'lib/rust-plots.rb', line 18
def y_label(label)
@options['ylab'] = label
return self
end
|
#y_range(range) ⇒ Object
30
31
32
33
34
|
# File 'lib/rust-plots.rb', line 30
def y_range(range)
@options['ylim'] = range
return self
end
|