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, log: false, x_label: nil, y_label: nil, title: nil, **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, x_label: nil, y_label: nil, title: nil, **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, log: false, x_label: nil, y_label: nil, title: nil, **options, &block) ⇒ Object
- #hist_plot(data: nil, x: nil, y: nil, color: nil, weights: nil, stat: :count, bins: :auto, bin_range: nil, common_bins: true, key_color: nil, palette: nil, color_order: nil, color_norm: nil, legend: true, x_label: nil, y_label: nil, title: nil, **options, &block) ⇒ Object
-
#line_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: nil, dashes: true, style_order: nil, units: nil, estimator: :mean, n_boot: 1000, random: nil, sort: true, err_style: :band, err_params: nil, error_bar: [:ci, 95], x_scale: :linear, y_scale: :linear, legend: :auto, x_label: nil, y_label: nil, title: nil, **options, &block) ⇒ Object
Line plot.
-
#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, style_order: nil, alpha: nil, legend: :auto, x_label: nil, y_label: nil, title: nil, **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, log: false, x_label: nil, y_label: nil, title: nil, **options, &block) ⇒ Object
Show the given data as rectangular bars.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/charty/plot_methods.rb', line 30 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, log: false, x_label: nil, y_label: nil, title: nil, **, &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, log: log, x_label: x_label, y_label: y_label, title: title, **, &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, x_label: nil, y_label: nil, title: nil, **options, &block) ⇒ Object
Show the distributions of the given data by boxes and whiskers.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/charty/plot_methods.rb', line 121 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, x_label: nil, y_label: nil, title: nil, **, &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, x_label: x_label, y_label: y_label, title: title, **, &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, log: false, x_label: nil, y_label: nil, title: nil, **options, &block) ⇒ Object
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 79 80 81 82 83 84 85 86 87 |
# File 'lib/charty/plot_methods.rb', line 48 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, log: false, x_label: nil, y_label: nil, title: nil, **, &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, x_label: x_label, y_label: y_label, title: title, ** ) do |plotter| plotter.value_label = "count" block.(plotter) unless block.nil? end end |
#hist_plot(data: nil, x: nil, y: nil, color: nil, weights: nil, stat: :count, bins: :auto, bin_range: nil, common_bins: true, key_color: nil, palette: nil, color_order: nil, color_norm: nil, legend: true, x_label: nil, y_label: nil, title: nil, **options, &block) ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/charty/plot_methods.rb', line 282 def hist_plot(data: nil, x: nil, y: nil, color: nil, weights: nil, stat: :count, bins: :auto, bin_range: nil, common_bins: true, key_color: nil, palette: nil, color_order: nil, color_norm: nil, legend: true, x_label: nil, y_label: nil, title: nil, **, &block) # TODO: support following arguments # - wiehgts # - binwidth # - discrete # - cumulative # - common_norm # - multiple # - element # - fill # - shrink # - kde # - kde_params # - line_params # - thresh # - pthresh # - pmax # - cbar # - cbar_params # - x_log_scale # - y_log_scale Plotters::HistogramPlotter.new( data: data, variables: { x: x, y: y, color: color }, weights: weights, stat: stat, bins: bins, bin_range: bin_range, common_bins: common_bins, key_color: key_color, palette: palette, color_order: color_order, color_norm: color_norm, legend: legend, x_label: x_label, y_label: y_label, title: title, **, &block) end |
#line_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: nil, dashes: true, style_order: nil, units: nil, estimator: :mean, n_boot: 1000, random: nil, sort: true, err_style: :band, err_params: nil, error_bar: [:ci, 95], x_scale: :linear, y_scale: :linear, legend: :auto, x_label: nil, y_label: nil, title: nil, **options, &block) ⇒ Object
Line plot
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/charty/plot_methods.rb', line 186 def line_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: nil, dashes: true, style_order: nil, units: nil, estimator: :mean, n_boot: 1000, random: nil, sort: true, err_style: :band, err_params: nil, error_bar: [:ci, 95], x_scale: :linear, y_scale: :linear, legend: :auto, x_label: nil, y_label: nil, title: nil, **, &block) Plotters::LinePlotter.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, dashes: dashes, style_order: style_order, units: units, estimator: estimator, n_boot: n_boot, random: random, sort: sort, err_style: err_style, err_params: err_params, error_bar: , x_scale: x_scale, y_scale: y_scale, legend: legend, x_label: x_label, y_label: y_label, title: title, **, &block ) 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, style_order: nil, alpha: nil, legend: :auto, x_label: nil, y_label: nil, title: nil, **options, &block) ⇒ Object
Scatter plot
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/charty/plot_methods.rb', line 255 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, style_order: nil, alpha: nil, legend: :auto, x_label: nil, y_label: nil, title: nil, **, &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, style_order: style_order, alpha: alpha, legend: legend, x_label: x_label, y_label: y_label, title: title, **, &block ) end |