In [2]:
Plot=require 'itorch.Plot'
In [4]:
x1 = torch.randn(40):mul(100)
y1 = torch.randn(40):mul(100)
In [15]:
function colormap(x)
assert(x:dim() == 1)
local mean = x:mean()
local std = x:std()
local c = {}
for i=1,x:size(1) do
local t = 99 * (x[i] - mean) / std
if t > 0 then
if t > 99 then t = 99 end
c[i] = '#' .. tostring(math.floor(t)) .. '0000'
else
t = -t
if t > 99 then t = 99 end
c[i] = '#0000' .. tostring(math.floor(t))
end
end
return c
end
c = colormap(x1)
plot = Plot():circle(x1, y1, c, 'hi'):draw()
In [ ]: