Module: Charty::PlotMethods
- Included in:
- Charty
- Defined in:
- lib/charty/plot_methods.rb
Instance Method Summary collapse
-
#bar_plot(x: nil, y: nil, color: nil, data: nil, order: nil, color_order: nil, estimator: :mean, ci: 95, n_boot: 1000, units: nil, random: nil, orient: nil, key_color: nil, palette: nil, saturation:, error_color: [0.26, 0.26, 0.26], error_width: nil, cap_size: nil, dodge: true, **options, &block) ⇒ Object
Show the given data as rectangular bars.
-
#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.
- #count_plot(x: nil, y: nil, color: nil, data: nil, order: nil, color_order: nil, orient: nil, key_color: nil, palette: nil, saturation:, dodge: true, **options, &block) ⇒ Object
-
#scatter_plot(x: nil, y: nil, color: nil, style: nil, size: nil, data: nil, key_color: nil, palette: nil, color_order: nil, color_norm: nil, sizes: nil, size_order: nil, size_norm: nil, markers: true, marker_order: nil, alpha: nil, legend: :auto, **options, &block) ⇒ Object
Scatter plot.
Instance Method Details
#bar_plot(x: nil, y: nil, color: nil, data: nil, order: nil, color_order: nil, estimator: :mean, ci: 95, n_boot: 1000, units: nil, random: nil, orient: nil, key_color: nil, palette: nil, saturation:, error_color: [0.26, 0.26, 0.26], error_width: nil, cap_size: nil, dodge: true, **options, &block) ⇒ Object
Show the given data as rectangular bars.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/charty/plot_methods.rb', line 26 def (x: nil, y: nil, color: nil, data: nil, order: nil, color_order: nil, estimator: :mean, ci: 95, n_boot: 1000, units: nil, random: nil, orient: nil, key_color: nil, palette: nil, saturation: 1r, error_color: [0.26, 0.26, 0.26], error_width: nil, cap_size: nil, dodge: true, **, &block) Plotters::BarPlotter.new( data: data, variables: { x: x, y: y, color: color }, order: order, orient: orient, estimator: estimator, ci: ci, n_boot: n_boot, units: units, random: random, color_order: color_order, key_color: key_color, palette: palette, saturation: saturation, error_color: error_color, error_width: error_width, cap_size: cap_size, dodge: dodge, **, &block ) end |
#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.
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, **, &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, **, &block ) end |
#count_plot(x: nil, y: nil, color: nil, data: nil, order: nil, color_order: nil, orient: nil, key_color: nil, palette: nil, saturation:, dodge: true, **options, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/charty/plot_methods.rb', line 43 def count_plot(x: nil, y: nil, color: nil, data: nil, order: nil, color_order: nil, orient: nil, key_color: nil, palette: nil, saturation: 1r, dodge: true, **, &block) case when x.nil? && !y.nil? x = y orient = :h when y.nil? && !x.nil? y = x orient = :v when !x.nil? && !y.nil? raise ArgumentError, "Unable to pass both x and y to count_plot" end Plotters::CountPlotter.new( data: data, variables: { x: x, y: y, color: color }, order: order, orient: orient, estimator: :count, ci: nil, units: nil, random: nil, color_order: color_order, key_color: key_color, palette: palette, saturation: saturation, dodge: dodge, ** ) do |plotter| plotter.value_label = "count" block.(plotter) unless block.nil? end end |
#scatter_plot(x: nil, y: nil, color: nil, style: nil, size: nil, data: nil, key_color: nil, palette: nil, color_order: nil, color_norm: nil, sizes: nil, size_order: nil, size_norm: nil, markers: true, marker_order: nil, alpha: nil, legend: :auto, **options, &block) ⇒ Object
Scatter plot
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/charty/plot_methods.rb', line 158 def scatter_plot(x: nil, y: nil, color: nil, style: nil, size: nil, data: nil, key_color: nil, palette: nil, color_order: nil, color_norm: nil, sizes: nil, size_order: nil, size_norm: nil, markers: true, marker_order: nil, alpha: nil, legend: :auto, **, &block) Plotters::ScatterPlotter.new( data: data, variables: { x: x, y: y, color: color, style: style, size: size }, key_color: key_color, palette: palette, color_order: color_order, color_norm: color_norm, sizes: sizes, size_order: size_order, size_norm: size_norm, markers: markers, marker_order: marker_order, alpha: alpha, legend: legend, **, &block ) end |