require '~/workspace/daru/lib/daru.rb' dv = Daru::Vector.new ['III']*10 + ['II']*5 + ['I']*5, type: :category, categories: ['I', 'II', 'III'] dv.type dv.plot(type: :bar) do |p, d| p.x_label 'Categories' p.y_label 'Frequency' end dv.plot(type: :bar, method: :percentage) do |p, d| p.x_label 'Categories' p.y_label 'Percentage (%)' end dv.plot(type: :bar, method: :fraction) do |p, d| p.x_label 'Categories' p.y_label 'Fraction' end df = Daru::DataFrame.new({ a: [1, 2, 4, -2, 5, 23, 0], b: [3, 1, 3, -6, 2, 1, 0], c: ['I', 'II', 'I', 'III', 'I', 'III', 'II'] }) df.to_category :c df[:c].type df.plot(type: :bar, x: :c) df = Daru::DataFrame.new({ a: [1, 2, 4, -2, 5, 23, 0], b: [3, 1, 3, -6, 2, 1, 0], c: ['I', 'II', 'I', 'III', 'I', 'III', 'II'] }) df.to_category :c df[:c].type df.plot(type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :color}) do |p, d| p.xrange [-10, 10] p.yrange [-10, 10] end df.plot(type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :shape}) do |p, d| p.xrange [-10, 10] p.yrange [-10, 10] end df.plot(type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :color, color: [:red, :blue, :green]}) do |p, d| p.xrange [-10, 10] p.yrange [-10, 10] end df.plot(type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :size, size: [300, 600, 900]}) do |p, d| p.xrange [-10, 10] p.yrange [-10, 10] end df = Daru::DataFrame.new({ a: [1, 2, 3, 4, 5, 6, 7, 8, 9], b: [2, 4, 6, 1, 3, 5, 6, 4, 3], c: ['I']*3 + ['II']*3 + ['III']*3 }) df.to_category :c df[:c].type df.plot type: :line, x: :a, y: :b, categorized: {by: :c, method: :color} do end df.plot type: :line, x: :a, y: :b, categorized: {by: :c, method: :stroke_width} do |p, d| p.xrange [-10, 10] p.yrange [-10, 10] end