In [1]:
require 'nyaplot'
Out[1]:
true
In [2]:
plot = Nyaplot::Plot.new
bar = plot.add(:bar, ['Persian', 'Maine Coon', 'American Shorthair'], [10,20,30])
Out[2]:
#<Nyaplot::Diagram:0x007f3fd6a5ea98 @properties={:type=>:bar, :options=>{:x=>"data0", :y=>"data1"}, :data=>"fcdb4e42-a4ac-484a-bd78-8422e6896bd1"}, @xrange=["Persian", "Maine Coon", "American Shorthair"], @yrange=[0, 30]>
In [3]:
plot.show
In [4]:
plot.x_label("Species")
plot.y_label("Number")
plot.show
In [5]:
colors = Nyaplot::Colors.qual
Out[5]:
rgb(228,26,28)rgb(55,126,184)rgb(77,175,74)rgb(152,78,163)rgb(255,127,0)rgb(255,255,51)rgb(166,86,40)rgb(247,129,191)rgb(153,153,153)
         
In [6]:
bar.color(colors)
plot.show
In [7]:
df = Nyaplot::DataFrame.new({species: ['Persian', 'Maine Coon', 'American Shorthair'], number: [10,20,30]})
Out[7]:
speciesnumber
Persian10
Maine Coon20
American Shorthair30
In [ ]: