class Charty::Plotters::BoxPlotter

Attributes

flier_size[R]
line_width[R]
whisker[R]

Public Class Methods

new(data: nil, variables: {}, **options, &block) click to toggle source
Calls superclass method
# File lib/charty/plotters/box_plotter.rb, line 7
def initialize(data: nil, variables: {}, **options, &block)
  x, y, color = variables.values_at(:x, :y, :color)
  super(x, y, color, data: data, **options, &block)
end

Public Instance Methods

flier_size=(val) click to toggle source
# File lib/charty/plotters/box_plotter.rb, line 14
def flier_size=(val)
  @flier_size = check_number(val, :flier_size, allow_nil: true)
end
line_width=(val) click to toggle source
# File lib/charty/plotters/box_plotter.rb, line 20
def line_width=(val)
  @line_width = check_number(val, :line_width, allow_nil: true)
end
whisker=(val) click to toggle source
# File lib/charty/plotters/box_plotter.rb, line 26
def whisker=(val)
  @whisker = check_number(val, :whisker, allow_nil: true)
end

Private Instance Methods

draw_box_plot(backend) click to toggle source
# File lib/charty/plotters/box_plotter.rb, line 36
        def draw_box_plot(backend)
  if @plot_colors.nil?
    plot_data = @plot_data.map do |group_data|
      unless group_data.empty?
        group_data = group_data.drop_na
        group_data unless group_data.empty?
      end
    end

    backend.box_plot(plot_data,
                     @group_names,
                     orient: orient,
                     colors: @colors,
                     gray: @gray,
                     dodge: dodge,
                     width: @width,
                     flier_size: flier_size,
                     whisker: whisker)
  else
    grouped_box_data = @color_names.map.with_index do |color_name, i|
      @plot_data.map.with_index do |group_data, j|
        unless group_data.empty?
          color_mask = @plot_colors[j].eq(color_name)
          group_data = group_data[color_mask].drop_na
          group_data unless group_data.empty?
        end
      end
    end

    backend.grouped_box_plot(grouped_box_data,
                             @group_names,
                             @color_names,
                             orient: orient,
                             colors: @colors,
                             gray: @gray,
                             dodge: dodge,
                             width: @width,
                             flier_size: flier_size,
                             whisker: whisker)
  end
end
render_plot(backend, **) click to toggle source
# File lib/charty/plotters/box_plotter.rb, line 30
        def render_plot(backend, **)
  draw_box_plot(backend)
  annotate_axes(backend)
  backend.invert_yaxis if orient == :h
end