Class: Rust::Plots::BasePlot
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BasePlot.
5
6
7
8
9
|
# File 'lib/rust/plots/core.rb', line 5
def initialize
@renderables = []
@options = Rust::Options.new
@override_options = true
end
|
Instance Method Details
#[]=(option, value) ⇒ Object
77
78
79
|
# File 'lib/rust/plots/core.rb', line 77
def []=(option, value)
@options[option.to_s] = value
end
|
#_add_renderable(renderable) ⇒ Object
70
71
72
73
74
75
|
# File 'lib/rust/plots/core.rb', line 70
def _add_renderable(renderable)
raise TypeError, "Expected Renderable" unless renderable.is_a?(Renderable)
@renderables << renderable
return self
end
|
#_do_not_override_options! ⇒ Object
81
82
83
|
# File 'lib/rust/plots/core.rb', line 81
def _do_not_override_options!
@override_options = false
end
|
#axis(axis) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/rust/plots/core.rb', line 43
def axis(axis)
@options['xaxt'] = 'n'
@options['yaxt'] = 'n'
self._add_renderable(axis)
return self
end
|
#color(color) ⇒ Object
64
65
66
67
68
|
# File 'lib/rust/plots/core.rb', line 64
def color(color)
@options['col'] = color
return self
end
|
#grid(grid) ⇒ Object
52
53
54
55
56
|
# File 'lib/rust/plots/core.rb', line 52
def grid(grid)
self._add_renderable(grid)
return self
end
|
#palette(size) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/rust/plots/core.rb', line 23
def palette(size)
if size <= 1
return ['black']
else
return Rust._pull("hcl.colors(n=#{size})")
end
end
|
#pdf(path, **options) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/rust/plots/core.rb', line 94
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
|
85
86
87
88
89
90
91
92
|
# File 'lib/rust/plots/core.rb', line 85
def show()
Rust.exclusive do
self._show
self._render_others
end
return self
end
|
#title(title) ⇒ Object
58
59
60
61
62
|
# File 'lib/rust/plots/core.rb', line 58
def title(title)
@options['main'] = title
return self
end
|
#x_label(label) ⇒ Object
11
12
13
14
15
|
# File 'lib/rust/plots/core.rb', line 11
def x_label(label)
@options['xlab'] = label
return self
end
|
#x_range(range) ⇒ Object
31
32
33
34
35
|
# File 'lib/rust/plots/core.rb', line 31
def x_range(range)
@options['xlim'] = range
return self
end
|
#y_label(label) ⇒ Object
17
18
19
20
21
|
# File 'lib/rust/plots/core.rb', line 17
def y_label(label)
@options['ylab'] = label
return self
end
|
#y_range(range) ⇒ Object
37
38
39
40
41
|
# File 'lib/rust/plots/core.rb', line 37
def y_range(range)
@options['ylim'] = range
return self
end
|