class Charty::Plotter

Attributes

table[R]

Public Class Methods

new(backend_name) click to toggle source
# File lib/charty/plotter.rb, line 3
def initialize(backend_name)
  backend_class = Backends.find_backend_class(backend_name)
  @backend = backend_class.new
end

Public Instance Methods

bar(**args, &block) click to toggle source
# File lib/charty/plotter.rb, line 118
def bar(**args, &block)
  context = RenderContext.new :bar, **args, &block
  context.apply(@backend)
end
barh(**args, &block) click to toggle source
# File lib/charty/plotter.rb, line 123
def barh(**args, &block)
  context = RenderContext.new :barh, **args, &block
  context.apply(@backend)
end
box_plot(**args, &block) click to toggle source
# File lib/charty/plotter.rb, line 128
def box_plot(**args, &block)
  context = RenderContext.new :box_plot, **args, &block
  context.apply(@backend)
end
bubble(**args, &block) click to toggle source
# File lib/charty/plotter.rb, line 133
def bubble(**args, &block)
  context = RenderContext.new :bubble, **args, &block
  context.apply(@backend)
end
curve(**args, &block) click to toggle source
# File lib/charty/plotter.rb, line 138
def curve(**args, &block)
  context = RenderContext.new :curve, **args, &block
  context.apply(@backend)
end
error_bar(**args, &block) click to toggle source
# File lib/charty/plotter.rb, line 148
def error_bar(**args, &block)
  context = RenderContext.new :error_bar, **args, &block
  context.apply(@backend)
end
hist(**args, &block) click to toggle source
# File lib/charty/plotter.rb, line 153
def hist(**args, &block)
  context = RenderContext.new :hist, **args, &block
  context.apply(@backend)
end
layout(definition=:horizontal) click to toggle source
# File lib/charty/plotter.rb, line 158
def layout(definition=:horizontal)
  Layout.new(@backend, definition)
end
scatter(**args, &block) click to toggle source
# File lib/charty/plotter.rb, line 143
def scatter(**args, &block)
  context = RenderContext.new :scatter, **args, &block
  context.apply(@backend)
end
table=(data, **kwargs) click to toggle source
# File lib/charty/plotter.rb, line 8
def table=(data, **kwargs)
  @table = Charty::Table.new(data)
end
to_bar(x, y, **args, &block) click to toggle source
# File lib/charty/plotter.rb, line 14
def to_bar(x, y, **args, &block)
  seriesx = table[x]
  seriesy = table[y]
  xrange = (seriesx.min)..(seriesx.max)
  yrange = (seriesy.min)..(seriesy.max)
  bar do
    series seriesx, seriesy
    range x: xrange, y: yrange
    xlabel x
    ylabel y
  end
end
to_barh(x, y, **args, &block) click to toggle source
# File lib/charty/plotter.rb, line 27
def to_barh(x, y, **args, &block)
  seriesx = table[x]
  seriesy = table[y]
  xrange = (seriesx.min)..(seriesx.max)
  yrange = (seriesy.min)..(seriesy.max)
  barh do
    series seriesx, seriesy
    range x: xrange, y: yrange
    xlabel x
    ylabel y
  end
end
to_box_plot(x, y, **args, &block) click to toggle source
# File lib/charty/plotter.rb, line 40
def to_box_plot(x, y, **args, &block)
  serieses = [table[x], table[y]]
  xrange = 0..serieses.size
  yrange = (serieses.flatten.min - 1)..(serieses.flatten.max + 1)
  box_plot do
    data serieses
    range x: xrange, y: yrange
    xlabel x
    ylabel y
  end
end
to_bubble(x, y, z, **args, &block) click to toggle source
# File lib/charty/plotter.rb, line 52
def to_bubble(x, y, z, **args, &block)
  seriesx = table[x]
  seriesy = table[y]
  seriesz = table[z]
  xrange = (seriesx.min)..(seriesx.max)
  yrange = (seriesy.min)..(seriesy.max)
  bubble do
    series seriesx, seriesy, seriesz
    range x: xrange, y: yrange
    xlabel x
    ylabel y
  end
end
to_curve(x, y, **args, &block) click to toggle source
# File lib/charty/plotter.rb, line 66
def to_curve(x, y, **args, &block)
  seriesx = table[x]
  seriesy = table[y]
  xrange = (seriesx.min)..(seriesx.max)
  yrange = (seriesy.min)..(seriesy.max)
  curve do
    series seriesx, seriesy
    range x: xrange, y: yrange
    xlabel x
    ylabel y
  end
end
to_error_bar(x, y, **args, &block) click to toggle source
# File lib/charty/plotter.rb, line 92
def to_error_bar(x, y, **args, &block)
  # TODO: It is not yet decided how to include data including xerror and yerror.
  seriesx = table[x]
  seriesy = table[y]
  xrange = (seriesx.min)..(seriesx.max)
  yrange = (seriesy.min)..(seriesy.max)
  error_bar do
    series seriesx, seriesy
    range x: xrange, y: yrange
    xlabel x
    ylabel y
  end
end
to_hst(x, y, **args, &block) click to toggle source
# File lib/charty/plotter.rb, line 106
def to_hst(x, y, **args, &block)
  serieses = [table[x], table[y]]
  xrange = (serieses.flatten.min - 1)..(serieses.flatten.max + 1)
  yrange = 0..serieses[0].size
  hist do
    data serieses
    range x: xrange, y: yrange
    xlabel x
    ylabel y
  end
end
to_scatter(x, y, **args, &block) click to toggle source
# File lib/charty/plotter.rb, line 79
def to_scatter(x, y, **args, &block)
  seriesx = table[x]
  seriesy = table[y]
  xrange = (seriesx.min)..(seriesx.max)
  yrange = (seriesy.min)..(seriesy.max)
  scatter do
    series seriesx, seriesy
    range x: xrange, y: yrange
    xlabel x
    ylabel y
  end
end