class Charty::Plotters::RelationalPlotter
Attributes
color_norm[R]
dashes[R]
input_format[R]
legend[R]
markers[R]
plot_data[R]
size[R]
size_norm[R]
size_order[R]
sizes[R]
style[R]
style_order[R]
units[R]
var_types[R]
variables[R]
Public Class Methods
new(x, y, color, style, size, data: nil, **options, &block)
click to toggle source
Calls superclass method
Charty::Plotters::AbstractPlotter::new
# File lib/charty/plotters/relational_plotter.rb, line 431 def initialize(x, y, color, style, size, data: nil, **options, &block) super(x, y, color, data: data, **options, &block) self.style = style self.size = size setup_variables end
Public Instance Methods
color_norm=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 462 def color_norm=(val) unless val.nil? raise NotImplementedError, "Specifying color_norm is not supported yet" end end
dashes=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 497 def dashes=(val) @dashes = check_dashes(val) end
flat_structure()
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 424 def flat_structure { x: :index, y: :values } end
legend=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 513 def legend=(val) case val when :auto, :brief, :full, false @legend = val when "auto", "brief", "full" @legend = val.to_sym else raise ArgumentError, "invalid value of legend (%p for :auto, :brief, :full, or false)" % val end end
markers=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 488 def markers=(val) @markers = check_markers(val) end
size=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 458 def size=(val) @size = check_dimension(val, :size) end
size_norm=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 481 def size_norm=(val) unless val.nil? raise NotImplementedError, "Specifying size_order is not supported yet" end end
size_order=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 474 def size_order=(val) unless val.nil? raise NotImplementedError, "Specifying size_order is not supported yet" end end
sizes=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 469 def sizes=(val) # NOTE: the value check will be perfomed in SizeMapper @sizes = val end
style=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 454 def style=(val) @style = check_dimension(val, :style) end
style_order=(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 506 def style_order=(val) unless val.nil? raise NotImplementedError, "Specifying style_order is not supported yet" end end
units=(units)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 450 def units=(units) @units = check_dimension(units, :units) end
Private Instance Methods
annotate_axes(backend)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 618 def annotate_axes(backend) # TODO end
check_dashes(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 501 def check_dashes(val) # TODO val end
check_markers(val)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 492 def check_markers(val) # TODO val end
map_color(palette: nil, order: nil, norm: nil)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 622 def map_color(palette: nil, order: nil, norm: nil) @color_mapper = ColorMapper.new(self, palette, order, norm) end
map_size(sizes: nil, order: nil, norm: nil)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 626 def map_size(sizes: nil, order: nil, norm: nil) @size_mapper = SizeMapper.new(self, sizes, order, norm) end
map_style(markers: nil, dashes: nil, order: nil)
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 630 def map_style(markers: nil, dashes: nil, order: nil) @style_mapper = StyleMapper.new(self, markers, dashes, order) end
setup_variables()
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 527 def setup_variables if x.nil? && y.nil? @input_format = :wide setup_variables_with_wide_form_dataset else @input_format = :long setup_variables_with_long_form_dataset end @var_types = @plot_data.columns.map { |k| [k, variable_type(@plot_data[k], :categorical)] }.to_h end
setup_variables_with_long_form_dataset()
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 581 def setup_variables_with_long_form_dataset self.data = {} if data.nil? plot_data = {} variables = {} { x: self.x, y: self.y, color: self.color, style: self.style, size: self.size, units: self.units }.each do |key, val| next if val.nil? if data.column?(val) plot_data[key] = data[val] variables[key] = val else case val when Charty::Vector plot_data[key] = val variables[key] = val.name else raise ArgumentError, "Could not interpret value %p for parameter %p" % [val, key] end end end @plot_data = Charty::Table.new(plot_data) @variables = variables.select do |var, name| @plot_data[var].notnull.any? end end
setup_variables_with_wide_form_dataset()
click to toggle source
# File lib/charty/plotters/relational_plotter.rb, line 541 def setup_variables_with_wide_form_dataset unless color.nil? && style.nil? && size.nil? vars = [] vars << "color" unless color.nil? vars << "style" unless style.nil? vars << "size" unless size.nil? raise ArgumentError, "Unable to assign the following variables in wide-form data: " + vars.join(", ") end if data.nil? || data.empty? @plot_data = Charty::Table.new({}) @variables = {} return end flat = data.is_a?(Charty::Vector) if flat @plot_data = {} @variables = {} [:x, :y].each do |var| case self.flat_structure[var] when :index @plot_data[var] = data.index.to_a @variables[var] = data.index.name when :values @plot_data[var] = data.to_a @variables[var] = data.name end end @plot_data = Charty::Table.new(@plot_data) else raise NotImplementedError, "wide-form input is not supported" end end