charty 0.2.7 → 0.2.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/charty.gemspec +1 -0
  3. data/examples/bar_plot.rb +19 -0
  4. data/examples/box_plot.rb +17 -0
  5. data/examples/scatter_plot.rb +17 -0
  6. data/images/penguins_body_mass_g_flipper_length_mm_species_scatter_plot.png +0 -0
  7. data/images/penguins_body_mass_g_flipper_length_mm_species_sex_scatter_plot.png +0 -0
  8. data/images/penguins_species_body_mass_g_bar_plot_h.png +0 -0
  9. data/images/penguins_species_body_mass_g_bar_plot_v.png +0 -0
  10. data/images/penguins_species_body_mass_g_box_plot_h.png +0 -0
  11. data/images/penguins_species_body_mass_g_box_plot_v.png +0 -0
  12. data/images/penguins_species_body_mass_g_sex_bar_plot_v.png +0 -0
  13. data/images/penguins_species_body_mass_g_sex_box_plot_v.png +0 -0
  14. data/lib/charty/backends/plotly.rb +53 -22
  15. data/lib/charty/backends/plotly_helpers/notebook_renderer.rb +4 -1
  16. data/lib/charty/backends/pyplot.rb +73 -0
  17. data/lib/charty/backends/unicode_plot.rb +16 -11
  18. data/lib/charty/index.rb +9 -0
  19. data/lib/charty/plot_methods.rb +46 -10
  20. data/lib/charty/plotters/abstract_plotter.rb +41 -9
  21. data/lib/charty/plotters/bar_plotter.rb +39 -0
  22. data/lib/charty/plotters/categorical_plotter.rb +9 -1
  23. data/lib/charty/plotters/distribution_plotter.rb +44 -7
  24. data/lib/charty/plotters/histogram_plotter.rb +97 -35
  25. data/lib/charty/plotters/line_plotter.rb +38 -5
  26. data/lib/charty/plotters/scatter_plotter.rb +4 -2
  27. data/lib/charty/statistics.rb +2 -2
  28. data/lib/charty/table.rb +30 -23
  29. data/lib/charty/table_adapters/arrow_adapter.rb +53 -0
  30. data/lib/charty/table_adapters/base_adapter.rb +88 -0
  31. data/lib/charty/table_adapters/daru_adapter.rb +41 -1
  32. data/lib/charty/table_adapters/hash_adapter.rb +58 -10
  33. data/lib/charty/table_adapters/pandas_adapter.rb +49 -1
  34. data/lib/charty/table_adapters.rb +1 -0
  35. data/lib/charty/vector.rb +30 -2
  36. data/lib/charty/vector_adapters/array_adapter.rb +1 -1
  37. data/lib/charty/vector_adapters/arrow_adapter.rb +156 -0
  38. data/lib/charty/vector_adapters/daru_adapter.rb +3 -6
  39. data/lib/charty/vector_adapters/narray_adapter.rb +10 -1
  40. data/lib/charty/vector_adapters/nmatrix_adapter.rb +1 -5
  41. data/lib/charty/vector_adapters/numpy_adapter.rb +4 -0
  42. data/lib/charty/vector_adapters/pandas_adapter.rb +10 -1
  43. data/lib/charty/vector_adapters/vector_adapter.rb +62 -0
  44. data/lib/charty/vector_adapters.rb +22 -0
  45. data/lib/charty/version.rb +1 -1
  46. metadata +23 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e39148cc6e6fd7916cdfbe5dacda3bab8f95068cbe3ceb4dff673d9688487d0
4
- data.tar.gz: 5743d17f30055707fe39004f99bb30fb2cb10b164dbf9b222f000068cc800708
3
+ metadata.gz: eac796ba17aeb9a82a312d7099c898a2350abaf34c3fad80ea1afd1483de1797
4
+ data.tar.gz: 8001339bd86377ab3693cc2eeb0a826c04c4ea4e08d58e3a10e99849a273cd58
5
5
  SHA512:
6
- metadata.gz: 562b312fb4ca59995d19930f404d6162f432f7731752e5a9016132b6b2696a507f6d7523d5eb6e5bc0141273726d2608b1351b497f2c200cec0fda5204e4fc19
7
- data.tar.gz: 213f83930bc1bd809ae98af41d0608793c356b234064e9f2ec79b96e76b1c301a331fc44c9c04fc0f3f188f65b780b59af449dca206f68ec310cb121b6bd0e41
6
+ metadata.gz: 3679334bb56834f7fb1067878c60e7601375e05d6adf63e566eb2cd3847a7ce1423bb27d0104f666854c8343840706a8e14dcc12bc8420ae062b8144d3f6ebc2
7
+ data.tar.gz: f4bbec96ae815cd758b67a993355fe5e42a10b91d7ef351e63570ec84fa618e65e4c2df4006f2d3431738c8b82b6a5dcf74d79a9b4ce005f89f18fd2ae88d31d
data/charty.gemspec CHANGED
@@ -42,4 +42,5 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency "activerecord"
43
43
  spec.add_development_dependency "sqlite3"
44
44
  spec.add_development_dependency "iruby", ">= 0.7.0"
45
+ spec.add_development_dependency "csv"
45
46
  end
@@ -0,0 +1,19 @@
1
+ # This example generates box_plot results in README.md
2
+
3
+ require "charty"
4
+ require "datasets"
5
+ require "matplotlib"
6
+
7
+ Charty::Backends.use(:pyplot)
8
+ Matplotlib.use(:agg)
9
+
10
+ penguins = Datasets::Penguins.new
11
+
12
+ Charty.bar_plot(data: penguins, x: :species, y: :body_mass_g)
13
+ .save("penguins_species_body_mass_g_bar_plot_v.png")
14
+
15
+ Charty.bar_plot(data: penguins, x: :body_mass_g, y: :species)
16
+ .save("penguins_species_body_mass_g_bar_plot_h.png")
17
+
18
+ Charty.bar_plot(data: penguins, x: :species, y: :body_mass_g, color: :sex)
19
+ .save("penguins_species_body_mass_g_sex_bar_plot_v.png")
@@ -0,0 +1,17 @@
1
+ require "charty"
2
+ require "datasets"
3
+ require "matplotlib"
4
+
5
+ Charty::Backends.use(:pyplot)
6
+ Matplotlib.use(:agg)
7
+
8
+ penguins = Datasets::Penguins.new
9
+
10
+ Charty.box_plot(data: penguins, x: :species, y: :body_mass_g)
11
+ .save("penguins_species_body_mass_g_box_plot_v.png")
12
+
13
+ Charty.box_plot(data: penguins, x: :body_mass_g, y: :species)
14
+ .save("penguins_species_body_mass_g_box_plot_h.png")
15
+
16
+ Charty.box_plot(data: penguins, x: :species, y: :body_mass_g, color: :sex)
17
+ .save("penguins_species_body_mass_g_sex_box_plot_v.png")
@@ -0,0 +1,17 @@
1
+ require "charty"
2
+ require "datasets"
3
+ require "matplotlib"
4
+
5
+ Charty::Backends.use(:pyplot)
6
+ Matplotlib.use(:agg)
7
+
8
+ penguins = Datasets::Penguins.new
9
+
10
+ Charty.scatter_plot(data: penguins, x: :body_mass_g, y: :flipper_length_mm)
11
+ .save("penguins_body_mass_g_flipper_length_mm_scatter_plot.png")
12
+
13
+ Charty.scatter_plot(data: penguins, x: :body_mass_g, y: :flipper_length_mm, color: :species)
14
+ .save("penguins_body_mass_g_flipper_length_mm_species_scatter_plot.png")
15
+
16
+ Charty.scatter_plot(data: penguins, x: :body_mass_g, y: :flipper_length_mm, color: :species, style: :sex)
17
+ .save("penguins_body_mass_g_flipper_length_mm_species_sex_scatter_plot.png")
@@ -134,10 +134,8 @@ module Charty
134
134
 
135
135
  if orient == :v
136
136
  x, y = bar_pos, values
137
- x = group_names unless group_names.nil?
138
137
  else
139
138
  x, y = values, bar_pos
140
- y = group_names unless group_names.nil?
141
139
  end
142
140
 
143
141
  trace = {
@@ -241,9 +239,9 @@ module Charty
241
239
  }
242
240
 
243
241
  if orient == :v
244
- trace.update(y: values, x: group_keys)
242
+ trace.update(y: values, x: group_keys.map(&:to_s))
245
243
  else
246
- trace.update(x: values, y: group_keys)
244
+ trace.update(x: values, y: group_keys.map(&:to_s))
247
245
  end
248
246
 
249
247
  trace
@@ -569,30 +567,35 @@ module Charty
569
567
  probability: "probability".freeze
570
568
  }.freeze
571
569
 
572
- def univariate_histogram(data, name, variable_name, stat,
573
- bin_start, bin_end, bin_size, alpha,
574
- color, color_mapper)
575
- orientation = case variable_name
576
- when :x
577
- :v
578
- else
579
- :h
580
- end
570
+ def univariate_histogram(hist, name, variable_name, stat,
571
+ alpha, color, key_color, color_mapper,
572
+ _multiple, _element, _fill, _shrink)
573
+ value_axis = variable_name
574
+ case value_axis
575
+ when :x
576
+ weights_axis = :y
577
+ orientation = :v
578
+ else
579
+ weights_axis = :x
580
+ orientation = :h
581
+ end
582
+
583
+ mid_points = hist.edges.each_cons(2).map {|a, b| a + (b - a) / 2 }
584
+
581
585
  trace = {
582
- type: "histogram",
586
+ type: :bar,
583
587
  name: name.to_s,
584
- variable_name => data.to_a,
588
+ value_axis => mid_points,
589
+ weights_axis => hist.weights,
585
590
  orientation: orientation,
586
- histnorm: PLOTLY_HISTNORM[stat],
587
- "#{variable_name}bins": {
588
- start: bin_start,
589
- end: bin_end,
590
- size: bin_size
591
- },
592
591
  opacity: alpha
593
592
  }
594
593
 
595
- if color
594
+ if color.nil?
595
+ trace[:marker] = {
596
+ color: key_color.to_rgb.to_hex_string
597
+ }
598
+ else
596
599
  trace[:marker] = {
597
600
  color: color_mapper[color].to_rgb.to_hex_string
598
601
  }
@@ -608,6 +611,11 @@ module Charty
608
611
  end
609
612
  end
610
613
 
614
+ def set_title(title)
615
+ @layout[:title] ||= {}
616
+ @layout[:title][:text] = title
617
+ end
618
+
611
619
  def set_xlabel(label)
612
620
  @layout[:xaxis] ||= {}
613
621
  @layout[:xaxis][:title] = label
@@ -652,6 +660,29 @@ module Charty
652
660
  @layout[:yaxis][:range] = [min, max]
653
661
  end
654
662
 
663
+ def set_xscale(scale)
664
+ scale = check_scale_type(scale, :xscale)
665
+ @layout[:xaxis] ||= {}
666
+ @layout[:xaxis][:type] = scale
667
+ end
668
+
669
+ def set_yscale(scale)
670
+ scale = check_scale_type(scale, :yscale)
671
+ @layout[:yaxis] ||= {}
672
+ @layout[:yaxis][:type] = scale
673
+ end
674
+
675
+ private def check_scale_type(val, name)
676
+ case
677
+ when :linear, :log
678
+ val
679
+ else
680
+ raise ArgumentError,
681
+ "Invalid #{name} type: %p" % val,
682
+ caller
683
+ end
684
+ end
685
+
655
686
  def disable_xaxis_grid
656
687
  # do nothing
657
688
  end
@@ -7,7 +7,7 @@ module Charty
7
7
  @initialized = false
8
8
  end
9
9
 
10
- def activate()
10
+ def activate
11
11
  return if @initialized
12
12
 
13
13
  unless IRubyHelper.iruby_notebook?
@@ -49,6 +49,9 @@ module Charty
49
49
  </script>
50
50
  END_SCRIPT
51
51
  end
52
+ IRuby.display(script, mime: "text/html")
53
+ @initialized = true
54
+ nil
52
55
  end
53
56
 
54
57
  def render(figure, element_id: nil, post_script: nil)
@@ -14,6 +14,7 @@ module Charty
14
14
 
15
15
  def initialize
16
16
  @pyplot = ::Matplotlib::Pyplot
17
+ @default_edgecolor = Colors["white"].to_rgb
17
18
  @default_line_width = ::Matplotlib.rcParams["lines.linewidth"]
18
19
  @default_marker_size = ::Matplotlib.rcParams["lines.markersize"]
19
20
  end
@@ -575,6 +576,47 @@ module Charty
575
576
  min + x * (max - min)
576
577
  end
577
578
 
579
+ def univariate_histogram(hist, name, variable_name, stat,
580
+ alpha, color, key_color, color_mapper,
581
+ multiple, element, fill, shrink)
582
+ mid_points = hist.edges.each_cons(2).map {|a, b| a + (b - a) / 2 }
583
+ orient = variable_name == :x ? :v : :h
584
+ width = shrink * (hist.edges[1] - hist.edges[0])
585
+
586
+ kw = {align: :edge}
587
+
588
+ color = if color.nil?
589
+ key_color.to_rgb
590
+ else
591
+ color_mapper[color].to_rgb
592
+ end
593
+
594
+ alpha = 1r unless fill
595
+
596
+ if fill
597
+ kw[:facecolor] = color.to_rgba(alpha: alpha).to_hex_string
598
+ if multiple == :stack || multiple == :fill || element == :bars
599
+ kw[:edgecolor] = @default_edgecolor.to_hex_string
600
+ else
601
+ kw[:edgecolor] = color.to_hex_string
602
+ end
603
+ elsif element == :bars
604
+ kw.delete(:facecolor)
605
+ kw[:edgecolor] = color.to_rgba(alpha: alpha).to_hex_string
606
+ else
607
+ kw[:color] = color.to_rgba(alpha: alpha).to_hex_string
608
+ end
609
+
610
+ kw[:label] = name unless name.nil?
611
+
612
+ ax = @pyplot.gca
613
+ if orient == :v
614
+ ax.bar(mid_points, hist.weights, width, **kw)
615
+ else
616
+ ax.barh(mid_points, hist.weights, width, **kw)
617
+ end
618
+ end
619
+
578
620
  private def locator_to_legend_entries(locator, limits)
579
621
  vmin, vmax = limits
580
622
  dtype = case vmin
@@ -620,6 +662,10 @@ module Charty
620
662
  end
621
663
  end
622
664
 
665
+ def set_title(title)
666
+ @pyplot.gca.set_title(String(title))
667
+ end
668
+
623
669
  def set_xlabel(label)
624
670
  @pyplot.gca.set_xlabel(String(label))
625
671
  end
@@ -652,6 +698,27 @@ module Charty
652
698
  @pyplot.gca.set_ylim(Float(min), Float(max))
653
699
  end
654
700
 
701
+ def set_xscale(scale)
702
+ scale = check_scale_type(scale, :xscale)
703
+ @pyplot.gca.set_xscale(scale)
704
+ end
705
+
706
+ def set_yscale(scale)
707
+ scale = check_scale_type(scale, :yscale)
708
+ @pyplot.gca.set_yscale(scale)
709
+ end
710
+
711
+ private def check_scale_type(val, name)
712
+ case
713
+ when :linear, :log
714
+ val
715
+ else
716
+ raise ArgumentError,
717
+ "Invalid #{name} type: %p" % val,
718
+ caller
719
+ end
720
+ end
721
+
655
722
  def disable_xaxis_grid
656
723
  @pyplot.gca.xaxis.grid(false)
657
724
  end
@@ -673,6 +740,11 @@ module Charty
673
740
  nil
674
741
  end
675
742
 
743
+ def render_mimebundle(include: [], exclude: [])
744
+ show
745
+ {}
746
+ end
747
+
676
748
  SAVEFIG_OPTIONAL_PARAMS = [
677
749
  :dpi, :quality, :optimize, :progressive, :facecolor, :edgecolor,
678
750
  :orientation, :papertype, :transparent, :bbox_inches, :pad_inches,
@@ -686,6 +758,7 @@ module Charty
686
758
  params[key] = kwargs[key] if kwargs.key?(key)
687
759
  end
688
760
  @pyplot.savefig(filename, **params)
761
+ @pyplot.close
689
762
  end
690
763
 
691
764
  def show
@@ -16,16 +16,16 @@ module Charty
16
16
  @layout = {}
17
17
  end
18
18
 
19
- def bar(bar_pos, values, color: nil)
19
+ def bar(bar_pos, _group_names, values, colors, _orient, **kwargs)
20
20
  @figure = {
21
21
  type: :bar,
22
22
  bar_pos: bar_pos,
23
- values: values
23
+ values: values,
24
24
  }
25
25
  end
26
26
 
27
- def box_plot(plot_data, positions, color:, gray:)
28
- @figure = { type: :box, data: plot_data }
27
+ def box_plot(plot_data, positions, orient:, **kwargs)
28
+ @figure = { type: :box, data: plot_data, orient: orient }
29
29
  end
30
30
 
31
31
  def set_xlabel(label)
@@ -52,13 +52,18 @@ module Charty
52
52
  # do nothing
53
53
  end
54
54
 
55
- def show
56
- case @figure[:type]
57
- when :bar
58
- plot = ::UnicodePlot.barplot(@layout[:xtick_labels], @figure[:values], xlabel: @layout[:xlabel])
59
- when :box
60
- plot = ::UnicodePlot.boxplot(@layout[:xtick_labels], @figure[:data], xlabel: @layout[:xlabel])
61
- end
55
+ def render(**kwargs)
56
+ plot = case @figure[:type]
57
+ when :bar
58
+ ::UnicodePlot.barplot(@layout[:xtick_labels], @figure[:values], xlabel: @layout[:xlabel])
59
+ when :box
60
+ xlabel = if @figure[:orient] == :v
61
+ @layout[:ylabel]
62
+ else
63
+ @layout[:xlabel]
64
+ end
65
+ ::UnicodePlot.boxplot(@layout[:xtick_labels], @figure[:data], xlabel: xlabel)
66
+ end
62
67
  sio = StringIO.new
63
68
  class << sio
64
69
  def tty?; true; end
data/lib/charty/index.rb CHANGED
@@ -199,6 +199,15 @@ module Charty
199
199
  end
200
200
  end
201
201
 
202
+ def loc(key)
203
+ case values
204
+ when Pandas::Index
205
+ values.get_loc(key)
206
+ else
207
+ super
208
+ end
209
+ end
210
+
202
211
  def union(other)
203
212
  other = PandasIndex.try_convert(other)
204
213
  # NOTE: Using `sort=False` in pandas.Index#union does not produce pandas.RangeIndex.
@@ -23,19 +23,24 @@ module Charty
23
23
  # @param cap_size Width of the caps on error bars.
24
24
  # @param dodge [true,false] If true, bar position is shifted along the
25
25
  # categorical axis for avoid overlapping when the color-dimension is used.
26
+ # @param log [true,false] Set the value-axis (e.g. Y-axis if orient is :v) to be log scale.
27
+ # @param x_label [String,Symbol,#to_str,nil] X-axis label.
28
+ # @param y_label [String,Symbol,#to_str,nil] Y-axis label.
29
+ # @param title [String,Symbol,#to_str,nil] Title text.
26
30
  def bar_plot(x: nil, y: nil, color: nil, data: nil,
27
31
  order: nil, color_order: nil,
28
32
  estimator: :mean, ci: 95, n_boot: 1000, units: nil, random: nil,
29
33
  orient: nil, key_color: nil, palette: nil, saturation: 1r,
30
34
  error_color: [0.26, 0.26, 0.26], error_width: nil, cap_size: nil,
31
- dodge: true, **options, &block)
35
+ dodge: true, log: false, x_label: nil, y_label: nil, title: nil,
36
+ **options, &block)
32
37
  Plotters::BarPlotter.new(
33
38
  data: data, variables: { x: x, y: y, color: color },
34
39
  order: order, orient: orient,
35
40
  estimator: estimator, ci: ci, n_boot: n_boot, units: units, random: random,
36
41
  color_order: color_order, key_color: key_color, palette: palette, saturation: saturation,
37
42
  error_color: error_color, error_width: error_width, cap_size: cap_size,
38
- dodge: dodge,
43
+ dodge: dodge, log: log, x_label: x_label, y_label: y_label, title: title,
39
44
  **options, &block
40
45
  )
41
46
  end
@@ -43,7 +48,8 @@ module Charty
43
48
  def count_plot(x: nil, y: nil, color: nil, data: nil,
44
49
  order: nil, color_order: nil,
45
50
  orient: nil, key_color: nil, palette: nil, saturation: 1r,
46
- dodge: true, **options, &block)
51
+ dodge: true, log: false, x_label: nil, y_label: nil, title: nil,
52
+ **options, &block)
47
53
  case
48
54
  when x.nil? && !y.nil?
49
55
  x = y
@@ -70,6 +76,9 @@ module Charty
70
76
  palette: palette,
71
77
  saturation: saturation,
72
78
  dodge: dodge,
79
+ x_label: x_label,
80
+ y_label: y_label,
81
+ title: title,
73
82
  **options
74
83
  ) do |plotter|
75
84
  plotter.value_label = "count"
@@ -106,11 +115,15 @@ module Charty
106
115
  # @param whisker Propotion of the IQR past the low and high quartiles to
107
116
  # extend the plot whiskers. Points outside of this range will be
108
117
  # treated as outliers.
118
+ # @param x_label [String,Symbol,#to_str,nil] X-axis label.
119
+ # @param y_label [String,Symbol,#to_str,nil] Y-axis label.
120
+ # @param title [String,Symbol,#to_str,nil] Title text.
109
121
  def box_plot(x: nil, y: nil, color: nil, data: nil,
110
122
  order: nil, color_order: nil,
111
123
  orient: nil, key_color: nil, palette: nil, saturation: 1r,
112
124
  width: 0.8r, dodge: true, flier_size: 5, line_width: nil,
113
- whisker: 1.5, **options, &block)
125
+ whisker: 1.5, x_label: nil, y_label: nil, title: nil,
126
+ **options, &block)
114
127
  Plotters::BoxPlotter.new(
115
128
  data: data,
116
129
  variables: { x: x, y: y, color: color },
@@ -125,6 +138,9 @@ module Charty
125
138
  flier_size: flier_size,
126
139
  line_width: line_width,
127
140
  whisker: whisker,
141
+ x_label: x_label,
142
+ y_label: y_label,
143
+ title: title,
128
144
  **options,
129
145
  &block
130
146
  )
@@ -164,13 +180,18 @@ module Charty
164
180
  # :full, every group will get an entry in the legend. If :auto,
165
181
  # choose between brief or full representation based on number of
166
182
  # levels. If false, no legend data is added and no legend is drawn.
183
+ # @param x_label [String,Symbol,#to_str,nil] X-axis label.
184
+ # @param y_label [String,Symbol,#to_str,nil] Y-axis label.
185
+ # @param title [String,Symbol,#to_str,nil] Title text.
167
186
  def line_plot(x: nil, y: nil, color: nil, style: nil, size: nil,
168
187
  data: nil, key_color: nil, palette: nil, color_order: nil,
169
188
  color_norm: nil, sizes: nil, size_order: nil, size_norm: nil,
170
189
  markers: nil, dashes: true, style_order: nil,
171
190
  units: nil, estimator: :mean, n_boot: 1000, random: nil,
172
191
  sort: true, err_style: :band, err_params: nil, error_bar: [:ci, 95],
173
- x_scale: :linear, y_scale: :linear, legend: :auto, **options, &block)
192
+ x_scale: :linear, y_scale: :linear, legend: :auto,
193
+ x_label: nil, y_label: nil, title: nil,
194
+ **options, &block)
174
195
  Plotters::LinePlotter.new(
175
196
  data: data,
176
197
  variables: { x: x, y: y, color: color, style: style, size: size },
@@ -195,6 +216,9 @@ module Charty
195
216
  x_scale: x_scale,
196
217
  y_scale: y_scale,
197
218
  legend: legend,
219
+ x_label: x_label,
220
+ y_label: y_label,
221
+ title: title,
198
222
  **options,
199
223
  &block
200
224
  )
@@ -225,11 +249,14 @@ module Charty
225
249
  # :full, every group will get an entry in the legend. If :auto,
226
250
  # choose between brief or full representation based on number of
227
251
  # levels. If false, no legend data is added and no legend is drawn.
252
+ # @param x_label [String,Symbol,#to_str,nil] X-axis label.
253
+ # @param y_label [String,Symbol,#to_str,nil] Y-axis label.
254
+ # @param title [String,Symbol,#to_str,nil] Title text.
228
255
  def scatter_plot(x: nil, y: nil, color: nil, style: nil, size: nil,
229
256
  data: nil, key_color: nil, palette: nil, color_order: nil,
230
257
  color_norm: nil, sizes: nil, size_order: nil, size_norm: nil,
231
258
  markers: true, style_order: nil, alpha: nil, legend: :auto,
232
- **options, &block)
259
+ x_label: nil, y_label: nil, title: nil, **options, &block)
233
260
  Plotters::ScatterPlotter.new(
234
261
  data: data,
235
262
  variables: { x: x, y: y, color: color, style: style, size: size },
@@ -244,22 +271,25 @@ module Charty
244
271
  style_order: style_order,
245
272
  alpha: alpha,
246
273
  legend: legend,
274
+ x_label: x_label,
275
+ y_label: y_label,
276
+ title: title,
247
277
  **options,
248
278
  &block
249
279
  )
250
280
  end
251
281
 
252
- def hist_plot(data: nil, x: nil, y: nil, color: nil,
282
+ def hist_plot(data: nil, x: nil, y: nil, color: nil, weights: nil,
253
283
  stat: :count, bins: :auto,
284
+ bin_range: nil, common_bins: true,
254
285
  key_color: nil, palette: nil, color_order: nil, color_norm: nil,
255
- legend: true, **options, &block)
286
+ legend: true, x_label: nil, y_label: nil, title: nil,
287
+ **options, &block)
256
288
  # TODO: support following arguments
257
289
  # - wiehgts
258
290
  # - binwidth
259
- # - binrange
260
291
  # - discrete
261
292
  # - cumulative
262
- # - common_bins
263
293
  # - common_norm
264
294
  # - multiple
265
295
  # - element
@@ -278,13 +308,19 @@ module Charty
278
308
  Plotters::HistogramPlotter.new(
279
309
  data: data,
280
310
  variables: { x: x, y: y, color: color },
311
+ weights: weights,
281
312
  stat: stat,
282
313
  bins: bins,
314
+ bin_range: bin_range,
315
+ common_bins: common_bins,
283
316
  key_color: key_color,
284
317
  palette: palette,
285
318
  color_order: color_order,
286
319
  color_norm: color_norm,
287
320
  legend: legend,
321
+ x_label: x_label,
322
+ y_label: y_label,
323
+ title: title,
288
324
  **options,
289
325
  &block)
290
326
  end