Sha256: 38c98abfbead341c7bcd868e2c28ec3f556dca80b54dd6f3278988543baac903

Contents?: true

Size: 1012 Bytes

Versions: 1

Compression:

Stored size: 1012 Bytes

Contents

require 'plotrb'

raw_data = pdata.name('iris').url('iris_data.json')
xs = linear_scale.name('x').from('iris.sepalWidth').to_width.nicely
ys = linear_scale.name('y').from('iris.petalLength').to_height.nicely
cs = ordinal_scale.name('c').from('iris.species').range(["#800", "#080", "#008"])

xaxis = x_axis.scale(xs).offset(5).ticks(5).title('Sepal Width')
yaxis = y_axis.scale(ys).offset(5).ticks(5).title('Petal Length')

lgnd = legend.fill(cs).title('Species') do
	properties(:symbols) do
		fill_opacity 0.5
        stroke :transparent
    end
end

mark = symbol_mark.from(raw_data) do
	enter do 
		x	{ scale(xs).field('sepalWidth') }
		y 	{ scale(ys).field('petalLength') }
		fill	{ scale(cs).field('species') }
		fill_opacity		0.5
	end
	update do
		size 100
		stroke 'transparent'
	end
	hover do
		size 300
		stroke 'white'
	end
end

vis = visualization.name('arc').width(200).height(200) do
	data raw_data
	scales xs, ys, cs
	axes xaxis, yaxis
	legends lgnd
	marks mark
end

puts vis.generate_spec(:pretty)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plotrb-0.0.1 examples/scatter.rb