Method: Charty::PlotMethods#box_plot

Defined in:
lib/charty/plot_methods.rb

#box_plot(x: nil, y: nil, color: nil, data: nil, order: nil, color_order: nil, orient: nil, key_color: nil, palette: nil, saturation:, width:, dodge: true, flier_size: 5, line_width: nil, whisker: 1.5, **options, &block) ⇒ Object

Show the distributions of the given data by boxes and whiskers.

Parameters:

  • x (defaults to: nil)

    X-dimension input for plotting long-Form data.

  • y (defaults to: nil)

    Y-dimension input for plotting long-form data.

  • color (defaults to: nil)

    Color-dimension input for plotting long-form data.

  • data (defaults to: nil)

    Dataset for plotting.

  • order (defaults to: nil)

    Order of the categorical dimension to plot the categorical levels in.

  • color_order (defaults to: nil)

    Order of the color dimension to plot the categorical levels in.

  • orient (defaults to: nil)

    Orientation of the plot (:v for vertical, or :h for horizontal).

  • key_color (defaults to: nil)

    Color for all of the elements, or seed for a gradient palette.

  • palette (defaults to: nil)

    Colors to use for the different levels of the color-dimension variable.

  • saturation

    Propotion of the original saturation to draw colors.

  • width

    Width of a full element when not using the color-dimension, or width of all the elements for one level of the major grouping variable.

  • dodge (true, false) (defaults to: true)

    If true, bar position is shifted along the categorical axis for avoid overlapping when the color-dimension is used.

  • flier_size (defaults to: 5)

    Size of the markers used to indicate outlier observations.

  • line_width (defaults to: nil)

    Width of the gray lines that frame the plot elements.

  • whisker (defaults to: 1.5)

    Propotion of the IQR past the low and high quartiles to extend the plot whiskers. Points outside of this range will be treated as outliers.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/charty/plot_methods.rb', line 109

def box_plot(x: nil, y: nil, color: nil, data: nil,
             order: nil, color_order: nil,
             orient: nil, key_color: nil, palette: nil, saturation: 1r,
             width: 0.8r, dodge: true, flier_size: 5, line_width: nil,
             whisker: 1.5, **options, &block)
  Plotters::BoxPlotter.new(
    data: data,
    variables: { x: x, y: y, color: color },
    order: order,
    color_order: color_order,
    orient: orient,
    key_color: key_color,
    palette: palette,
    saturation: saturation,
    width: width,
    dodge: dodge,
    flier_size: flier_size,
    line_width: line_width,
    whisker: whisker,
    **options,
    &block
  )
end