class Statsample::Graph::Boxplot

Boxplot

From Wikipedia: In descriptive statistics, a box plot or boxplot (also known as a box-and-whisker diagram or plot) is a convenient way of graphically depicting groups of numerical data through their five-number summaries: the smallest observation (sample minimum), lower quartile (Q1), median (Q2), upper quartile (Q3), and largest observation (sample maximum). A boxplot may also indicate which observations, if any, might be considered outliers.

Usage

Svg output

a=[1,2,3,4].to_scale
b=[3,4,5,6].to_scale
puts Statsample::Graph::Boxplot.new(:vectors=>[a,b]).to_svg

Using ReportBuilder

a=[1,2,3,4].to_scale
b=[3,4,5,6].to_scale
rb=ReportBuilder.new
rb.add(Statsample::Graph::Boxplot.new(:vectors=>[a,b]))
rb.save_html('boxplot.html')

Boxplot

From Wikipedia: In descriptive statistics, a box plot or boxplot (also known as a box-and-whisker diagram or plot) is a convenient way of graphically depicting groups of numerical data through their five-number summaries: the smallest observation (sample minimum), lower quartile (Q1), median (Q2), upper quartile (Q3), and largest observation (sample maximum). A boxplot may also indicate which observations, if any, might be considered outliers.

Usage

Svg output

a=[1,2,3,4].to_scale
b=[3,4,5,6].to_scale
puts Statsample::Graph::Boxplot.new(:vectors=>[a,b]).to_svg

Using ReportBuilder

a=[1,2,3,4].to_scale
b=[3,4,5,6].to_scale
rb=ReportBuilder.new
rb.add(Statsample::Graph::Boxplot.new(:vectors=>[a,b]))
rb.save_html('boxplot.html')

Attributes

groups[RW]

Array with assignation to groups of bars For example, for four vectors,

boxplot.groups=[1,2,1,3]

Assign same color to first and third element, and different to second and fourth

height[RW]

Total height of Boxplot

label_angle[RW]

The rotation angle, in radians. Text is rotated clockwise relative to the anchor location. For example, with the default left alignment, an angle of Math.PI / 2 causes text to proceed downwards. The default angle is zero.

margin_bottom[RW]

Bottom margin

margin_left[RW]

Left margin

margin_right[RW]

Right margin

margin_top[RW]

Top margin

maximum[RW]

Maximum value on y-axis. Automaticly defined from data

minimum[RW]

Minimum value on y-axis. Automaticly defined from data

name[RW]
vectors[RW]

Vectors to box-ploting

width[RW]

Total width of Boxplot

x_scale[R]
y_scale[R]

Public Class Methods

new(opts=Hash.new) click to toggle source

Create a new Boxplot. Parameters: Hash of options

  • :vectors: Array of vectors

  • :groups: Array of same size as :vectors:, with name of groups

    to colorize vectors
# File lib/statsample/graph/boxplot.rb, line 58
def initialize(opts=Hash.new)
  @vectors=opts.delete :vectors
  raise "You should define vectors" if @vectors.nil?
  
  opts_default={
    :name=>_("Boxplot"),
    :groups=>nil,
    :width=>400,
    :height=>300,
    :margin_top=>10,
    :margin_bottom=>20,
    :margin_left=>20,
    :margin_right=>20,
    :minimum=>nil,
    :maximum=>nil,
    :label_angle=>0
  }
  @opts=opts_default.merge(opts)
  opts_default.keys.each {|k| send("#{k}=", @opts[k]) }
end

Public Instance Methods

to_svg() click to toggle source

Returns SVG with scatterplot

# File lib/statsample/graph/boxplot.rb, line 231
def to_svg
  rp=rubyvis_panel
  rp.render
  rp.to_svg
end