Iris植物分类数据可视化(散点图)(python-nvd3)

标签:
python |
分类: 可视化 |
from
nvd3
import
scatterChart
import
pandas
as
pd
#scikit-learn
库内置著名的Iris植物分类数据集
from
sklearn.datasets
import
load_iris
#
源数据data读取
dataset
=
load_iris()
data
=
pd.DataFrame(dataset.data,columns
=
('sepalLength','sepalWidth','petalLength','petalWidth'))
data['species']
=
dataset.target
type
=
"Iris Morphology"
#
创建画布
chart
=
scatterChart(name=type,
height=600,
width=1024,
x_is_date=False)
#
设置标题
chart.set_containerheader("
#
数据分类
xdata1
=
list(data[data['species']==0]['sepalLength'])
ydata1
=
list(data[data['species']==0]['sepalWidth'])
xdata2
=
list(data[data['species']==0]['petalLength'])
ydata2
=
list(data[data['species']==0]['petalWidth'])
xdata3
=
list(data[data['species']==1]['sepalLength'])
ydata3
=
list(data[data['species']==1]['sepalWidth'])
xdata4
=
list(data[data['species']==1]['petalLength'])
ydata4
=
list(data[data['species']==1]['petalWidth'])
xdata5
=
list(data[data['species']==2]['sepalLength'])
ydata5
=
list(data[data['species']==2]['sepalWidth'])
xdata6
=
list(data[data['species']==2]['petalLength'])
ydata6
=
list(data[data['species']==2]['petalWidth'])
#
设置图例属性,还有一个color属性,不过不建议设,没有默认好看。
kwargs1
=
{'shape':
'circle',
'size':
'1'}
kwargs2
=
{'shape':
'cross',
'size':
'10'}
kwargs3
=
{'shape':
'triangle-up',
'size':
'15'}
kwargs4
=
{'shape':
'triangle-down',
'size':
'30'}
kwargs5
=
{'shape':
'diamond',
'size':
'10'}
kwargs6
=
{'shape':
'square',
'size':
'20'}
#
设置指向插件显示内容,散点图不显示
extra_serie
=
{"tooltip":
{"y_start":
"",
"y_end":
" calls"}}
chart.add_serie(name="sepal
0",
y=ydata1,
x=xdata1,
extra=extra_serie,
**kwargs1)
chart.add_serie(name="petal
0",
y=ydata2,
x=xdata2,
extra=extra_serie,
**kwargs2)
chart.add_serie(name="sepal
1",
y=ydata3,
x=xdata3,
extra=extra_serie,
**kwargs3)
chart.add_serie(name="petal
1",
y=ydata4,
x=xdata4,
extra=extra_serie,
**kwargs4)
chart.add_serie(name="sepal
2",
y=ydata5,
x=xdata5,
extra=extra_serie,
**kwargs5)
chart.add_serie(name="petal
2",
y=ydata6,
x=xdata6,
extra=extra_serie,
**kwargs6)
#
生成html源码
chart.buildhtml()
#
保存本地
output_file
=
open('Iris_Morphology.html',
'w')
output_file.write(chart.htmlcontent)
output_file.close()
http://s14/mw690/005Zx9zgzy7dJL0gUk51d&690
http://wx4/large/77ec4507gy1fiw6q6hmedj21kw11x166.jpg
html源码
lang="en"> | |
charset="utf-8" /> | |
href="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.7.0/nv.d3.min.css" rel="stylesheet" /> | |
Iris Morphology |
|
id="iris_morphology">style="width:1024px;height:600px;">
|
|
data_iris_morphology=[{"values": [{"x": 5.1, "y": 3.5, "shape": "circle", "size": "1"}, {"x": 4.9, "y": 3.0, "shape": "circle", "size": "1"}, {"x": 4.7, "y": 3.2, "shape": "circle", "size": "1"}, {"x": 4.6, "y": 3.1, "shape": "circle", "size": "1"}, {"x": 5.0, "y": 3.6, "shape": "circle", "size": "1"}, {"x": 5.4, "y": 3.9, "shape": "circle", "size": "1"}, {"x": 4.6, "y": 3.4, "shape": "circle", "size": "1"}, {"x": 5.0, "y": 3.4, "shape": "circle", "size": "1"}, {"x": 4.4, "y": 2.9, "shape": "circle", "size": "1"}, {"x": 4.9, "y": 3.1, "shape": "circle", "size": "1"}, {"x": 5.4, "y": 3.7, "shape": "circle", "size": "1"}, {"x": 4.8, "y": 3.4, "shape": "circle", "size": "1"}, {"x": 4.8, "y": 3.0, "shape": "circle", "size": "1"}, {"x": 4.3, "y": 3.0, "shape": "circle", "size": "1"}, {"x": 5.8, "y": 4.0, "shape": "circle", "size": "1"}, {"x": 5.7, "y": 4.4, "shape": "circle", "size": "1"}, {"x": 5.4, "y": 3.9, "shape": "circle", "size": "1"}, {"x": 5.1, "y": 3.5, "shape": "circle", "size": "1"}, {"x": 5.7, "y": 3.8, "shape": "circle", "size": "1"}, {"x": 5.1, "y": 3.8, "shape": "circle", "size": "1"}, {"x": 5.4, "y": 3.4, "shape": "circle", "size": "1"}, {"x": 5.1, "y": 3.7, "shape": "circle", "size": "1"}, {"x": 4.6, "y": 3.6, "shape": "circle", "size": "1"}, {"x": 5.1, "y": 3.3, "shape": "circle", "size": "1"}, {"x": 4.8, "y": 3.4, "shape": "circle", "size": "1"}, {"x": 5.0, "y": 3.0, "shape": "circle", "size": "1"}, {"x": 5.0, "y": 3.4, "shape": "circle", "size": "1"}, {"x": 5.2, "y": 3.5, "shape": "circle", "size": "1"}, {"x": 5.2, "y": 3.4, "shape": "circle", "size": "1"}, {"x": 4.7, "y": 3.2, "shape": "circle", "size": "1"}, {"x": 4.8, "y": 3.1, "shape": "circle", "size": "1"}, {"x": 5.4, "y": 3.4, "shape": "circle", "size": "1"}, {"x": 5.2, "y": 4.1, "shape": "circle", "size": "1"}, {"x": 5.5, "y": 4.2, "shape": "circle", "size": "1"}, {"x": 4.9, "y": 3.1, "shape": "circle", "size": "1"}, {"x": 5.0, "y": 3.2, "shape": "circle", "size": "1"}, {"x": 5.5, "y": 3.5, "shape": "circle", "size": "1"}, {"x": 4.9, "y": 3.1, "shape": "circle", "size": "1"}, {"x": 4.4, "y": 3.0, "shape": "circle", "size": "1"}, {"x": 5.1, "y": 3.4, "shape": "circle", "size": "1"}, {"x": 5.0, "y": 3.5, "shape": "circle", "size": "1"}, {"x": 4.5, "y": 2.3, "shape": "circle", "size": "1"}, {"x": 4.4, "y": 3.2, "shape": "circle", "size": "1"}, {"x": 5.0, "y": 3.5, "shape": "circle", "size": "1"}, {"x": 5.1, "y": 3.8, "shape": "circle", "size": "1"}, {"x": 4.8, "y": 3.0, "shape": "circle", "size": "1"}, {"x": 5.1, "y": 3.8, "shape": "circle", "size": "1"}, {"x": 4.6, "y": 3.2, "shape": "circle", "size": "1"}, {"x": 5.3, "y": 3.7, "shape": "circle", "size": "1"}, {"x": 5.0, "y": 3.3, "shape": "circle", "size": "1"}], "key": "sepal 0", "yAxis": "1"}, {"values": [{"x": 1.4, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.3, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.7, "y": 0.4, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.3, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.1, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.6, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.1, "shape": "cross", "size": "10"}, {"x": 1.1, "y": 0.1, "shape": "cross", "size": "10"}, {"x": 1.2, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.4, "shape": "cross", "size": "10"}, {"x": 1.3, "y": 0.4, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.3, "shape": "cross", "size": "10"}, {"x": 1.7, "y": 0.3, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.3, "shape": "cross", "size": "10"}, {"x": 1.7, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.4, "shape": "cross", "size": "10"}, {"x": 1.0, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.7, "y": 0.5, "shape": "cross", "size": "10"}, {"x": 1.9, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.6, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.6, "y": 0.4, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.6, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.6, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.4, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.1, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.1, "shape": "cross", "size": "10"}, {"x": 1.2, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.3, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.1, "shape": "cross", "size": "10"}, {"x": 1.3, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.3, "y": 0.3, "shape": "cross", "size": "10"}, {"x": 1.3, "y": 0.3, "shape": "cross", "size": "10"}, {"x": 1.3, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.6, "y": 0.6, "shape": "cross", "size": "10"}, {"x": 1.9, "y": 0.4, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.3, "shape": "cross", "size": "10"}, {"x": 1.6, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.5, "y": 0.2, "shape": "cross", "size": "10"}, {"x": 1.4, "y": 0.2, "shape": "cross", "size": "10"}], "key": "petal 0", "yAxis": "1"}, {"values": [{"x": 7.0, "y": 3.2, "shape": "triangle-up", "size": "15"}, {"x": 6.4, "y": 3.2, "shape": "triangle-up", "size": "15"}, {"x": 6.9, "y": 3.1, "shape": "triangle-up", "size": "15"}, {"x": 5.5, "y": 2.3, "shape": "triangle-up", "size": "15"}, {"x": 6.5, "y": 2.8, "shape": "triangle-up", "size": "15"}, {"x": 5.7, "y": 2.8, "shape": "triangle-up", "size": "15"}, {"x": 6.3, "y": 3.3, "shape": "triangle-up", "size": "15"}, {"x": 4.9, "y": 2.4, "shape": "triangle-up", "size": "15"}, {"x": 6.6, "y": 2.9, "shape": "triangle-up", "size": "15"}, {"x": 5.2, "y": 2.7, "shape": "triangle-up", "size": "15"}, {"x": 5.0, "y": 2.0, "shape": "triangle-up", "size": "15"}, {"x": 5.9, "y": 3.0, "shape": "triangle-up", "size": "15"}, {"x": 6.0, "y": 2.2, "shape": "triangle-up", "size": "15"}, {"x": 6.1, "y": 2.9, "shape": "triangle-up", "size": "15"}, {"x": 5.6, "y": 2.9, "shape": "triangle-up", "size": "15"}, {"x": 6.7, "y": 3.1, "shape": "triangle-up", "size": "15"}, {"x": 5.6, "y": 3.0, "shape": "triangle-up", "size": "15"}, {"x": 5.8, "y": 2.7, "shape": "triangle-up", "size": "15"}, {"x": 6.2, "y": 2.2, "shape": "triangle-up", "size": "15"}, {"x": 5.6, "y": 2.5, "shape": "triangle-up", "size": "15"}, {"x": 5.9, "y": 3.2, "shape": "triangle-up", "size": "15"}, {"x": 6.1, "y": 2.8, "shape": "triangle-up", "size": "15"}, {"x": 6.3, "y": 2.5, "shape": "triangle-up", "size": "15"}, {"x": 6.1, "y": 2.8, "shape": "triangle-up", "size": "15"}, {"x": 6.4, "y": 2.9, "shape": "triangle-up", "size": "15"}, {"x": 6.6, "y": 3.0, "shape": "triangle-up", "size": "15"}, {"x": 6.8, "y": 2.8, "shape": "triangle-up", "size": "15"}, {"x": 6.7, "y": 3.0, "shape": "triangle-up", "size": "15"}, {"x": 6.0, "y": 2.9, "shape": "triangle-up", "size": "15"}, {"x": 5.7, "y": 2.6, "shape": "triangle-up", "size": "15"}, {"x": 5.5, "y": 2.4, "shape": "triangle-up", "size": "15"}, {"x": 5.5, "y": 2.4, "shape": "triangle-up", "size": "15"}, {"x": 5.8, "y": 2.7, "shape": "triangle-up", "size": "15"}, {"x": 6.0, "y": 2.7, "shape": "triangle-up", "size": "15"}, {"x": 5.4, "y": 3.0, "shape": "triangle-up", "size": "15"}, {"x": 6.0, "y": 3.4, "shape": "triangle-up", "size": "15"}, {"x": 6.7, "y": 3.1, "shape": "triangle-up", "size": "15"}, {"x": 6.3, "y": 2.3, "shape": "triangle-up", "size": "15"}, {"x": 5.6, "y": 3.0, "shape": "triangle-up", "size": "15"}, {"x": 5.5, "y": 2.5, "shape": "triangle-up", "size": "15"}, {"x": 5.5, "y": 2.6, "shape": "triangle-up", "size": "15"}, {"x": 6.1, "y": 3.0, "shape": "triangle-up", "size": "15"}, {"x": 5.8, "y": 2.6, "shape": "triangle-up", "size": "15"}, {"x": 5.0, "y": 2.3, "shape": "triangle-up", "size": "15"}, {"x": 5.6, "y": 2.7, "shape": "triangle-up", "size": "15"}, {"x": 5.7, "y": 3.0, "shape": "triangle-up", "size": "15"}, {"x": 5.7, "y": 2.9, "shape": "triangle-up", "size": "15"}, {"x": 6.2, "y": 2.9, "shape": "triangle-up", "size": "15"}, {"x": 5.1, "y": 2.5, "shape": "triangle-up", "size": "15"}, {"x": 5.7, "y": 2.8, "shape": "triangle-up", "size": "15"}], "key": "sepal 1", "yAxis": "1"}, {"values": [{"x": 4.7, "y": 1.4, "shape": "triangle-down", "size": "30"}, {"x": 4.5, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 4.9, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 4.0, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.6, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 4.5, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.7, "y": 1.6, "shape": "triangle-down", "size": "30"}, {"x": 3.3, "y": 1.0, "shape": "triangle-down", "size": "30"}, {"x": 4.6, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 3.9, "y": 1.4, "shape": "triangle-down", "size": "30"}, {"x": 3.5, "y": 1.0, "shape": "triangle-down", "size": "30"}, {"x": 4.2, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 4.0, "y": 1.0, "shape": "triangle-down", "size": "30"}, {"x": 4.7, "y": 1.4, "shape": "triangle-down", "size": "30"}, {"x": 3.6, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.4, "y": 1.4, "shape": "triangle-down", "size": "30"}, {"x": 4.5, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 4.1, "y": 1.0, "shape": "triangle-down", "size": "30"}, {"x": 4.5, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 3.9, "y": 1.1, "shape": "triangle-down", "size": "30"}, {"x": 4.8, "y": 1.8, "shape": "triangle-down", "size": "30"}, {"x": 4.0, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.9, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 4.7, "y": 1.2, "shape": "triangle-down", "size": "30"}, {"x": 4.3, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.4, "y": 1.4, "shape": "triangle-down", "size": "30"}, {"x": 4.8, "y": 1.4, "shape": "triangle-down", "size": "30"}, {"x": 5.0, "y": 1.7, "shape": "triangle-down", "size": "30"}, {"x": 4.5, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 3.5, "y": 1.0, "shape": "triangle-down", "size": "30"}, {"x": 3.8, "y": 1.1, "shape": "triangle-down", "size": "30"}, {"x": 3.7, "y": 1.0, "shape": "triangle-down", "size": "30"}, {"x": 3.9, "y": 1.2, "shape": "triangle-down", "size": "30"}, {"x": 5.1, "y": 1.6, "shape": "triangle-down", "size": "30"}, {"x": 4.5, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 4.5, "y": 1.6, "shape": "triangle-down", "size": "30"}, {"x": 4.7, "y": 1.5, "shape": "triangle-down", "size": "30"}, {"x": 4.4, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.1, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.0, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.4, "y": 1.2, "shape": "triangle-down", "size": "30"}, {"x": 4.6, "y": 1.4, "shape": "triangle-down", "size": "30"}, {"x": 4.0, "y": 1.2, "shape": "triangle-down", "size": "30"}, {"x": 3.3, "y": 1.0, "shape": "triangle-down", "size": "30"}, {"x": 4.2, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.2, "y": 1.2, "shape": "triangle-down", "size": "30"}, {"x": 4.2, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 4.3, "y": 1.3, "shape": "triangle-down", "size": "30"}, {"x": 3.0, "y": 1.1, "shape": "triangle-down", "size": "30"}, {"x": 4.1, "y": 1.3, "shape": "triangle-down", "size": "30"}], "key": "petal 1", "yAxis": "1"}, {"values": [{"x": 6.3, "y": 3.3, "shape": "diamond", "size": "10"}, {"x": 5.8, "y": 2.7, "shape": "diamond", "size": "10"}, {"x": 7.1, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 6.3, "y": 2.9, "shape": "diamond", "size": "10"}, {"x": 6.5, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 7.6, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 4.9, "y": 2.5, "shape": "diamond", "size": "10"}, {"x": 7.3, "y": 2.9, "shape": "diamond", "size": "10"}, {"x": 6.7, "y": 2.5, "shape": "diamond", "size": "10"}, {"x": 7.2, "y": 3.6, "shape": "diamond", "size": "10"}, {"x": 6.5, "y": 3.2, "shape": "diamond", "size": "10"}, {"x": 6.4, "y": 2.7, "shape": "diamond", "size": "10"}, {"x": 6.8, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 5.7, "y": 2.5, "shape": "diamond", "size": "10"}, {"x": 5.8, "y": 2.8, "shape": "diamond", "size": "10"}, {"x": 6.4, "y": 3.2, "shape": "diamond", "size": "10"}, {"x": 6.5, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 7.7, "y": 3.8, "shape": "diamond", "size": "10"}, {"x": 7.7, "y": 2.6, "shape": "diamond", "size": "10"}, {"x": 6.0, "y": 2.2, "shape": "diamond", "size": "10"}, {"x": 6.9, "y": 3.2, "shape": "diamond", "size": "10"}, {"x": 5.6, "y": 2.8, "shape": "diamond", "size": "10"}, {"x": 7.7, "y": 2.8, "shape": "diamond", "size": "10"}, {"x": 6.3, "y": 2.7, "shape": "diamond", "size": "10"}, {"x": 6.7, "y": 3.3, "shape": "diamond", "size": "10"}, {"x": 7.2, "y": 3.2, "shape": "diamond", "size": "10"}, {"x": 6.2, "y": 2.8, "shape": "diamond", "size": "10"}, {"x": 6.1, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 6.4, "y": 2.8, "shape": "diamond", "size": "10"}, {"x": 7.2, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 7.4, "y": 2.8, "shape": "diamond", "size": "10"}, {"x": 7.9, "y": 3.8, "shape": "diamond", "size": "10"}, {"x": 6.4, "y": 2.8, "shape": "diamond", "size": "10"}, {"x": 6.3, "y": 2.8, "shape": "diamond", "size": "10"}, {"x": 6.1, "y": 2.6, "shape": "diamond", "size": "10"}, {"x": 7.7, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 6.3, "y": 3.4, "shape": "diamond", "size": "10"}, {"x": 6.4, "y": 3.1, "shape": "diamond", "size": "10"}, {"x": 6.0, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 6.9, "y": 3.1, "shape": "diamond", "size": "10"}, {"x": 6.7, "y": 3.1, "shape": "diamond", "size": "10"}, {"x": 6.9, "y": 3.1, "shape": "diamond", "size": "10"}, {"x": 5.8, "y": 2.7, "shape": "diamond", "size": "10"}, {"x": 6.8, "y": 3.2, "shape": "diamond", "size": "10"}, {"x": 6.7, "y": 3.3, "shape": "diamond", "size": "10"}, {"x": 6.7, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 6.3, "y": 2.5, "shape": "diamond", "size": "10"}, {"x": 6.5, "y": 3.0, "shape": "diamond", "size": "10"}, {"x": 6.2, "y": 3.4, "shape": "diamond", "size": "10"}, {"x": 5.9, "y": 3.0, "shape": "diamond", "size": "10"}], "key": "sepal 2", "yAxis": "1"}, {"values": [{"x": 6.0, "y": 2.5, "shape": "square", "size": "20"}, {"x": 5.1, "y": 1.9, "shape": "square", "size": "20"}, {"x": 5.9, "y": 2.1, "shape": "square", "size": "20"}, {"x": 5.6, "y": 1.8, "shape": "square", "size": "20"}, {"x": 5.8, "y": 2.2, "shape": "square", "size": "20"}, {"x": 6.6, "y": 2.1, "shape": "square", "size": "20"}, {"x": 4.5, "y": 1.7, "shape": "square", "size": "20"}, {"x": 6.3, "y": 1.8, "shape": "square", "size": "20"}, {"x": 5.8, "y": 1.8, "shape": "square", "size": "20"}, {"x": 6.1, "y": 2.5, "shape": "square", "size": "20"}, {"x": 5.1, "y": 2.0, "shape": "square", "size": "20"}, {"x": 5.3, "y": 1.9, "shape": "square", "size": "20"}, {"x": 5.5, "y": 2.1, "shape": "square", "size": "20"}, {"x": 5.0, "y": 2.0, "shape": "square", "size": "20"}, {"x": 5.1, "y": 2.4, "shape": "square", "size": "20"}, {"x": 5.3, "y": 2.3, "shape": "square", "size": "20"}, {"x": 5.5, "y": 1.8, "shape": "square", "size": "20"}, {"x": 6.7, "y": 2.2, "shape": "square", "size": "20"}, {"x": 6.9, "y": 2.3, "shape": "square", "size": "20"}, {"x": 5.0, "y": 1.5, "shape": "square", "size": "20"}, {"x": 5.7, "y": 2.3, "shape": "square", "size": "20"}, {"x": 4.9, "y": 2.0, "shape": "square", "size": "20"}, {"x": 6.7, "y": 2.0, "shape": "square", "size": "20"}, {"x": 4.9, "y": 1.8, "shape": "square", "size": "20"}, {"x": 5.7, "y": 2.1, "shape": "square", "size": "20"}, {"x": 6.0, "y": 1.8, "shape": "square", "size": "20"}, {"x": 4.8, "y": 1.8, "shape": "square", "size": "20"}, {"x": 4.9, "y": 1.8, "shape": "square", "size": "20"}, {"x": 5.6, "y": 2.1, "shape": "square", "size": "20"}, {"x": 5.8, "y": 1.6, "shape": "square", "size": "20"}, {"x": 6.1, "y": 1.9, "shape": "square", "size": "20"}, {"x": 6.4, "y": 2.0, "shape": "square", "size": "20"}, {"x": 5.6, "y": 2.2, "shape": "square", "size": "20"}, {"x": 5.1, "y": 1.5, "shape": "square", "size": "20"}, {"x": 5.6, "y": 1.4, "shape": "square", "size": "20"}, {"x": 6.1, "y": 2.3, "shape": "square", "size": "20"}, {"x": 5.6, "y": 2.4, "shape": "square", "size": "20"}, {"x": 5.5, "y": 1.8, "shape": "square", "size": "20"}, {"x": 4.8, "y": 1.8, "shape": "square", "size": "20"}, {"x": 5.4, "y": 2.1, "shape": "square", "size": "20"}, {"x": 5.6, "y": 2.4, "shape": "square", "size": "20"}, {"x": 5.1, "y": 2.3, "shape": "square", "size": "20"}, {"x": 5.1, "y": 1.9, "shape": "square", "size": "20"}, {"x": 5.9, "y": 2.3, "shape": "square", "size": "20"}, {"x": 5.7, "y": 2.5, "shape": "square", "size": "20"}, {"x": 5.2, "y": 2.3, "shape": "square", "size": "20"}, {"x": 5.0, "y": 1.9, "shape": "square", "size": "20"}, {"x": 5.2, "y": 2.0, "shape": "square", "size": "20"}, {"x": 5.4, "y": 2.3, "shape": "square", "size": "20"}, {"x": 5.1, "y": 1.8, "shape": "square", "size": "20"}], "key": "petal 2", "yAxis": "1"}]; | |
nv.addGraph(function() { | |
var chart = nv.models.scatterChart(); | |
chart.margin({top: 30, right: 60, bottom: 20, left: 60}); | |
var datum = data_iris_morphology; | |
chart.xAxis | |
.tickFormat(d3.format(',.02f')); | |
chart.yAxis | |
.tickFormat(d3.format(',.02f')); | |
chart.showLegend(true); | |
chart | |
.showDistX(true) | |
.showDistY(true) | |
.color(d3.scale.category10().range()); | |
d3.select('#iris_morphology svg') | |
.datum(datum) | |
.transition().duration(500) | |
.attr('width', 1024) | |
.attr('height', 600) | |
.call(chart); | |
}); | |