Method: Charty::Backends::Pyplot#grouped_box_plot

Defined in:
lib/charty/backends/pyplot.rb

#grouped_box_plot(plot_data, group_names, color_names, orient:, colors:, gray:, dodge:, width:, flier_size: 5, whisker: 1.5, notch: false) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/charty/backends/pyplot.rb', line 218

def grouped_box_plot(plot_data, group_names, color_names,
                     orient:, colors:, gray:, dodge:, width: 0.8r,
                     flier_size: 5, whisker: 1.5, notch: false)
  colors = Array(colors).map(&:to_hex_string)
  gray = gray.to_hex_string
  width = Float(width)
  flier_size = Float(flier_size)
  whisker = Float(whisker)

  offsets = color_offsets(color_names, dodge, width)
  orig_width = width
  width = Float(nested_width(color_names, dodge, width))

  color_names.each_with_index do |color_name, i|
    add_box_plot_legend(gray, colors[i], color_names[i])

    plot_data[i].each_with_index do |group_data, j|
      next if group_data.empty?

      position = j + offsets[i]
      draw_box_plot(group_data,
                    vert: (orient == :v),
                    position: position,
                    color: colors[i],
                    gray: gray,
                    width: width,
                    whisker: whisker,
                    flier_size: flier_size)
    end
  end
end