Nyaplot has an interface to various prepared colorsets. All of those colorsets are provided by Colorbrewer that is licensed under Apache License Version 2.0.
require 'nyaplot'
Use Nyaplot::Colors#lists to show the lists of prepared colorsets.
Nyaplot::Colors.lists
Try some of those colorsets.
Nyaplot::Colors.Pastel2
Nyaplot::Colors.jet
Nyaplot::Colors.GnBu
Nyaplot::Colors.binary
Nyaplot::Colors#seq return random colors that is suitable for sequential data. Similarly, Nyaplot::Colors#div returns colors for diverging data, and Nyaplot::Colors#qual is for qualitative data.
Nyaplot::Colors.seq
Nyaplot::Colors.div
Nyaplot::Colors.qual
Those methods can have one argument to specify required number of colors.
Nyaplot::Colors.seq(3)
Nyaplot::Colors.Spectral(11)
Use Nyaplot::Color to try your favorite color (Credits: fatalflaws)
Nyaplot::Color.new(["#DEDEDE", "#ACACAC", "#1F141C", "#4A173D", "#8C547E"])
Then try those colors in some plots.
plot = Nyaplot::Plot.new
bar = plot.add(:bar, ['Persian', 'Maine Coon', 'American Shorthair'], [10,20,30])
plot.show
colors = Nyaplot::Colors.qual(3)
bar.color(colors)
plot.show
x=[]; y=[]; fill=[]
-5.step(5, 1) do |i|
-5.step(5, 1) do |j|
x.push(i)
y.push(j)
val = Math.sin(Math.sqrt(i*i+j*j))/Math.sqrt(i*i+j*j)
fill.push((val.nan? ? 0 : val))
end
end
plot2 = Nyaplot::Plot.new
hm = plot2.add(:heatmap, x, y, fill)
hm.width(1)
hm.height(1)
plot2.legend(true)
plot2.show
colors = Nyaplot::Colors.GnBu
hm.color(colors)
plot2.show