@@ -7,29 +7,24 @@ class Axes < Base
77 LEGEND_MARGIN = TITLE_MARGIN = 20.0
88 LABEL_MARGIN = 10.0
99 DEFAULT_MARGIN = 20.0
10-
1110 THOUSAND_SEPARATOR = ',' . freeze
12-
1311 # FIXME: most of the below accessors should just be name= methods which
1412 # will access the required Artist and set the variable in there directly.
1513 # Range of X axis.
1614 attr_accessor :x_range
1715 # Range of Y axis.
18- attr_accessor :y_range ,
19- :text_font , :grid ,
20- :bounding_box , :origin ,
21- :title_shift , :title_margin
16+
17+ attr_accessor :y_range , :text_font , :grid , :bounding_box , :origin , :title_shift , :title_margin
18+
2219 # Main title for this Axes.
2320 attr_accessor :title
2421 # Rubyplot::Figure object to which this Axes belongs.
2522 attr_reader :figure
2623 # Array of plots contained in this Axes.
2724 attr_reader :plots
28-
2925 attr_reader :font , :marker_font_size , :legend_font_size ,
3026 :title_font_size , :scale , :font_color , :marker_color , :axes ,
31- :legend_margin , :backend , :marker_caps_height , :marker_font_size
32-
27+ :legend_margin , :backend , :marker_caps_height
3328 attr_reader :label_stagger_height
3429 # FIXME: possibly disposable attrs
3530 attr_reader :title_caps_height
@@ -51,30 +46,27 @@ class Axes < Base
5146 attr_accessor :num_x_ticks
5247
5348 # @param figure [Rubyplot::Figure] Figure object to which this Axes belongs.
54- def initialize figure
49+ def initialize ( figure )
5550 @figure = figure
56-
51+
5752 @x_title = ''
5853 @y_title = ''
5954 @x_axis_margin = 40.0
6055 @y_axis_margin = 40.0
6156 @x_range = [ nil , nil ]
6257 @y_range = [ nil , nil ]
63-
64- @title = ""
58+ @title = ''
6559 @title_shift = 0
6660 @title_margin = TITLE_MARGIN
6761 @text_font = :default
6862 @grid = true
6963 @bounding_box = true
7064 @plots = [ ]
71-
7265 @raw_rows = width * ( height /width )
73-
7466 @theme = Rubyplot ::Themes ::CLASSIC_WHITE
7567 vera_font_path = File . expand_path ( 'Vera.ttf' , ENV [ 'MAGICK_FONT_PATH' ] )
7668 @font = File . exist? ( vera_font_path ) ? vera_font_path : nil
77- @font_color = " #000000"
69+ @font_color = ' #000000'
7870 @marker_font_size = 15.0
7971 @legend_font_size = 20.0
8072 @legend_margin = LEGEND_MARGIN
@@ -90,7 +82,6 @@ def initialize figure
9082 @y_axis = Rubyplot ::Artist ::YAxis . new ( self )
9183 @x_ticks = nil
9284 @num_x_ticks = 5
93-
9485 @legend_box_position = :top
9586 end
9687
@@ -109,7 +100,7 @@ def legend_box_iy
109100 abs_x + @x_axis_margin + @legend_margin
110101 end
111102 end
112-
103+
113104 # Write an image to a file by communicating with the backend.
114105 # FIXME: (refactor) Currently draw first assigns default colors and then
115106 # performs consolidation etc of the data and then assigns the default X ticks.
@@ -128,60 +119,60 @@ def draw
128119 actually_draw
129120 end
130121
131- def scatter! * args , & block
122+ def scatter! ( * _args )
132123 plot = Rubyplot ::Artist ::Plot ::Scatter . new self
133124 yield ( plot ) if block_given?
134125 @plots << plot
135126 end
136127
137- def bar! * args , & block
128+ def bar! ( * _args )
138129 plot = Rubyplot ::Artist ::Plot ::Bar . new self
139130 yield ( plot ) if block_given?
140131 @plots << plot
141132 end
142133
143- def line! * args , & block
134+ def line! ( * _args )
144135 plot = Rubyplot ::Artist ::Plot ::Line . new self
145136 yield ( plot ) if block_given?
146137 @plots << plot
147138 end
148139
149- def area! * args , & block
140+ def area! ( * _args )
150141 plot = Rubyplot ::Artist ::Plot ::Area . new self
151142 yield ( plot ) if block_given?
152143 @plots << plot
153144 end
154145
155- def bubble! * args , & block
146+ def bubble! ( * _args )
156147 plot = Rubyplot ::Artist ::Plot ::Bubble . new self
157148 yield ( plot ) if block_given?
158149 @plots << plot
159150 end
160151
161- def dot! *args , &block
162- add_plot " Dot" , *args , &block
152+ def dot! ( *args , &block )
153+ add_plot ' Dot' , *args , &block
163154 end
164155
165- def stacked_bar! * args , & block
156+ def stacked_bar! ( * _args )
166157 plot = Rubyplot ::Artist ::Plot ::StackedBar . new self
167158 yield ( plot ) if block_given?
168159 @plots << plot
169160 end
170161
171- def write file_name
162+ def write ( file_name )
172163 @plots [ 0 ] . write file_name
173164 end
174-
165+
175166 # Absolute X co-ordinate of the Axes. Top left corner.
176167 def abs_x
177168 @figure . top_spacing * @figure . height + @figure . abs_x
178169 end
179-
170+
180171 # Absolute Y co-ordinate of the Axes. Top left corner.
181172 def abs_y
182173 @figure . top_spacing * @figure . height + @figure . abs_y
183174 end
184-
175+
185176 # Absolute width of the Axes in pixels.
186177 def width
187178 ( 1 - ( @figure . left_spacing + @figure . right_spacing ) ) * @figure . width
@@ -204,7 +195,7 @@ def x_title= x_title
204195 def y_title = y_title
205196 @y_axis . title = y_title
206197 end
207-
198+
208199 private
209200
210201 def assign_default_label_colors
@@ -242,29 +233,22 @@ def add_plot plot_type, *args, &block
242233 @plots << plot
243234 end
244235
245- def with_backend plot_type , *args
236+ def with_backend ( plot_type , *args )
246237 plot =
247238 case Rubyplot . backend
248239 when :magick
249240 Kernel . const_get ( "Rubyplot::MagickWrapper::Plot::#{ plot_type } " ) . new self , *args
250241 when :gr
251242 Kernel . const_get ( "Rubyplot::GRWrapper::Plot::#{ plot_type } " ) . new self , *args
252243 end
253-
254244 plot
255245 end
256246
257247 # Figure out the co-ordinates of the title text w.r.t Axes.
258248 def configure_title
259249 @title = Rubyplot ::Artist ::Text . new (
260- @title ,
261- self ,
262- abs_x : abs_x + width / 2 ,
263- abs_y : abs_y + @title_margin ,
264- font : @font ,
265- color : @font_color ,
266- pointsize : @title_font_size ,
267- internal_label : "axes title."
250+ @title , self , abs_x : abs_x + width / 2 , abs_y : abs_y + @title_margin , font : @font , color : @font_color ,
251+ pointsize : @title_font_size , internal_label : 'axes title.'
268252 )
269253 end
270254
@@ -276,7 +260,8 @@ def calculate_xy_axes_origin
276260 # Figure out co-ordinates of the legends
277261 def configure_legends
278262 @legend_box = Rubyplot ::Artist ::LegendBox . new (
279- self , abs_x : legend_box_ix , abs_y : legend_box_iy )
263+ self , abs_x : legend_box_ix , abs_y : legend_box_iy
264+ )
280265 end
281266
282267 # Make adjustments to the data that will be plotted. Maps the data
@@ -299,16 +284,15 @@ def actually_draw
299284
300285 def consolidate_plots
301286 bars = @plots . grep ( Rubyplot ::Artist ::Plot ::Bar )
302- if ! bars . empty?
287+ unless bars . empty?
303288 @plots . delete_if { |p | p . is_a? ( Rubyplot ::Artist ::Plot ::Bar ) }
304289 @plots << Rubyplot ::Artist ::Plot ::MultiBars . new ( self , bar_plots : bars )
305290 end
306291
307292 stacked_bars = @plots . grep ( Rubyplot ::Artist ::Plot ::StackedBar )
308- if ! stacked_bars . empty?
293+ unless stacked_bars . empty?
309294 @plots . delete_if { |p | p . is_a? ( Rubyplot ::Artist ::Plot ::StackedBar ) }
310- @plots << Rubyplot ::Artist ::Plot ::MultiStackedBar . new (
311- self , stacked_bars : stacked_bars )
295+ @plots << Rubyplot ::Artist ::Plot ::MultiStackedBar . new ( self , stacked_bars : stacked_bars )
312296 end
313297 end
314298
@@ -335,6 +319,9 @@ def set_yrange
335319 @y_axis . min_val = @y_range [ 0 ]
336320 @y_axis . max_val = @y_range [ 1 ]
337321 end
338- end # class Axes
339- end # moudle Artist
340- end # module Rubyplot
322+ end
323+ # class Axes
324+ end
325+ # moudle Artist
326+ end
327+ # module Rubyplot
0 commit comments