@@ -20,18 +20,9 @@ class Axes < Base
2020 attr_accessor :x_range
2121 # Range of Y axis.
2222 attr_accessor :y_range ,
23- :x_tick_count , :y_tick_count , : text_font, :grid ,
23+ :text_font , :grid ,
2424 :bounding_box , :x_axis_padding , :y_axis_padding , :origin ,
2525 :title_shift , :title_margin
26-
27- # A hash of names for the individual columns, where the key is the array
28- # index for the column this label represents.
29- #
30- # Not all columns need to be named.
31- #
32- # Example: 0 => 2005, 3 => 2006, 5 => 2007, 7 => 2008
33- attr_accessor :x_ticks
34- attr_accessor :y_ticks
3526 # Main title for this Axes.
3627 attr_accessor :title
3728 # Rubyplot::Figure object to which this Axes belongs.
@@ -71,8 +62,6 @@ def initialize figure
7162 @y_axis_margin = 40.0
7263 @x_range = [ nil , nil ]
7364 @y_range = [ nil , nil ]
74- @x_tick_count = :default
75- @y_tick_count = :default
7665
7766 @origin = [ nil , nil ]
7867 @title = ""
@@ -81,7 +70,6 @@ def initialize figure
8170 @text_font = :default
8271 @grid = true
8372 @bounding_box = true
84- @x_ticks = { }
8573 @plots = [ ]
8674
8775 @raw_rows = width * ( height /width )
@@ -124,6 +112,7 @@ def legend_box_iy
124112
125113 # Write an image to a file by communicating with the backend.
126114 def draw
115+ consolidate_plots
127116 configure_title
128117 calculate_xy_axes_origin
129118 configure_xy_axes
@@ -191,6 +180,10 @@ def height
191180 ( 1 - ( @figure . top_spacing + @figure . bottom_spacing ) ) * @figure . height
192181 end
193182
183+ def x_ticks = ticks_hash
184+ @x_ticks = ticks_hash
185+ end
186+
194187 private
195188
196189 def add_plot plot_type , *args , &block
@@ -300,6 +293,12 @@ def label_string(value, increment)
300293 parts [ 0 ] . gsub! ( /(\d )(?=(\d \d \d )+(?!\d ))/ , "\\ 1#{ THOUSAND_SEPARATOR } " )
301294 parts . join ( '.' )
302295 end
296+
297+ def consolidate_plots
298+ bars = @plots . map { |p | p . is_a? ( Rubyplot ::Artist ::Plot ::Bar ) }
299+ @plots . delete_if { |p | p . is_a? ( Rubyplot ::Artist ::Plot ::Bar ) }
300+ @plots << Rubyplot ::Artist ::Plot ::MultiBars . new ( self , bars )
301+ end
303302 end # class Axes
304303 end # moudle Artist
305304end # module Rubyplot
0 commit comments