This repository has been archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcreate_reference_images.rb
132 lines (99 loc) · 4.06 KB
/
create_reference_images.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
require_relative './lib/grruby'
x1 = [1, 2, 3, 4, 5]
y1 = [10, 20, 30, 40, 50]
values = [0, 24, -12, 48]
freqwise = [1, 2, 5, 6, 5, 9, 9, 1, 2, 9, 2, 6, 5]
portfolio_names = ['Apples', 'Oranges', 'Bananas']
portfolio = [20000, 8000, 34000]
a = Rubyplot::Figure.new
a.line! x1, y1
a.save 'spec/reference_images/single_plot_graph/line_graph.bmp'
a = Rubyplot::Figure.new
a.line! x1, y1, marker_size: 1
a.save 'spec/reference_images/single_plot_graph/line_marker_graph.bmp'
a = Rubyplot::Figure.new
a.line! x1, y1, line_color: :red, line_type: :dashed
a.save 'spec/reference_images/single_plot_graph/dash_line_marker_graph.bmp'
a = Rubyplot::Figure.new
a.scatter! x1, y1
a.save 'spec/reference_images/single_plot_graph/scatter_graph.bmp'
a = Rubyplot::Figure.new
a.scatter! x1, y1, marker_color: :green, marker_size: 2,
marker_type: :diagonal_cross
a.save 'spec/reference_images/single_plot_graph/scatter_cross_graph.bmp'
a = Rubyplot::Figure.new
a.bar! values
a.save 'spec/reference_images/single_plot_graph/bar_graph.bmp'
a = Rubyplot::Figure.new
a.bar! values, bar_color: :red
a.save 'spec/reference_images/single_plot_graph/red_bar_graph.bmp'
a = Rubyplot::Figure.new
a.bar! values, bar_color: :orange, bar_gap: 1
a.save 'spec/reference_images/single_plot_graph/orange_spaced_bar_graph.bmp'
bars_data = [[12, 4, 53, 24],
[4, 34, 8, 25],
[20, 9, 31, 2],
[56, 12, 84, 30]]
a = Rubyplot::Figure.new
a.stacked_bar! bars_data
a.save 'spec/reference_images/single_plot_graph/stacked_bar_graph.bmp'
a = Rubyplot::Figure.new
a.stacked_bar! bars_data, bar_colors: [:black, :red, :green, :blue]
a.save 'spec/reference_images/single_plot_graph/user_color_stacked_bar_graph.bmp'
open = [10, 15, 24, 18]
high = [20, 25, 30, 18]
low = [5, 13, 15, 3]
close = [15, 24, 18, 4]
a = Rubyplot::Figure.new
a.candlestick! open, high, low, close
a.save 'spec/reference_images/single_plot_graph/candlestick_plot.bmp'
a = Rubyplot::Figure.new
a.candlestick! open, high, low, close, up_color: :blue, down_color: :black
a.save 'spec/reference_images/single_plot_graph/candlestick_diff_color_plot.bmp'
a = Rubyplot::Figure.new
a.stacked_bar_z! bars_data
a.save 'spec/reference_images/single_plot_graph/stacked_bar_z_graph.bmp'
a = Rubyplot::Figure.new
a.stacked_bar_z! bars_data, bar_colors: [:black, :red, :green, :blue]
a.save 'spec/reference_images/single_plot_graph/user_color_stacked_bar_z_graph.bmp'
x1 = [-10, 0, 5, 28]
y1 = [1, 2, 3, 4]
x2 = [2, 4, 16]
y2 = [10, 20, -40]
a = Rubyplot::Figure.new
a.title 'My cool graph'
a.line! x1, y1
a.scatter! x2, y2
a.save 'spec/reference_images/multi_plot_graph/line_scatter_graph.bmp'
x1 = [1, 2, 3, 4, 5]
y1 = [10, 20, 30, 40, 50]
x2 = [2, 4, 16]
y2 = [10, 20, -40]
values = [0, 24, -12, 48]
bars_data = [[12, 4, 53, 24],
[4, 34, 8, 25],
[20, 9, 31, 2],
[56, 12, 84, 30]]
open = [10, 15, 24, 18]
high = [20, 25, 30, 18]
low = [5, 13, 15, 3]
close = [15, 24, 18, 4]
a = Rubyplot::Figure.new
a.subplot!(2, 1, 1)
a.line! x1, y1
a.subplot!(2, 1, 2)
a.scatter! x2, y2
a.save 'spec/reference_images/subplots/two_vertical.bmp'
a = Rubyplot::Figure.new
a.subplot!(2, 2, 1)
a.line! x1, y1, marker_size: 1
a.scatter! x2, y2
a.subplot!(2, 2, 2)
a.scatter! x2, y2
a.subplot!(2, 2, 3)
a.line! x1, y1, line_color: :red, line_type: :dashed
a.subplot!(2, 2, 4)
a.candlestick! open, high, low, close, up_color: :blue, down_color: :black
a.subplot!(2, 2, 3)
a.bar! values, bar_color: :orange, bar_gap: 1
a.save 'spec/reference_images/subplots/two_by_two_grid.bmp'