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
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
Total height of Boxplot
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.
Bottom margin
Left margin
Right margin
Top margin
Maximum value on y-axis. Automaticly defined from data
Minimum value on y-axis. Automaticly defined from data
Vectors to box-ploting
Total width of Boxplot
Public Class Methods
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
Returns SVG with scatterplot
# File lib/statsample/graph/boxplot.rb, line 231 def to_svg rp=rubyvis_panel rp.render rp.to_svg end