plotly
https://plot.ly/python/ plotly是现代平台的敏捷商业智能和数据科学库,它作为一款开源的绘图库,可以应用于Python、R、MATLAB、Excel、JavaScript和jupyter等多种语言,主要使用的js进行图形绘制,实现过程中主要就是调用plotly的函数接口,底层实现完全被隐藏,便于初学者的掌握。
Basic Example
In [6]:
import
plotly.plotly
as
py
import
plotly.graph_objs
as
go
py
.
sign_in
(
'deamoncao'
,
'*******'
)
# 注意:这里是plotly网站的用户名和密码
trace
=
go
.
Bar
(
x
=
[
2
,
4
,
6
],
y
=
[
10
,
12
,
15
])
data
=
[
trace
]
layout
=
go
.
Layout
(
title
=
'A Simple Plot'
,
width
=
800
,
height
=
640
)
fig
=
go
.
Figure
(
data
=
data
,
layout
=
layout
)
py
.
image
.
save_as
(
fig
,
filename
=
'a-simple-plot.png'
)
from
IPython.display
import
Image
Image
(
'a-simple-plot.png'
)
Out[6]:
In [22]:
import
plotly.plotly
as
py
import
plotly.graph_objs
as
go
import
numpy
as
np
y0
=
np
.
random
.
randn
(
50
)
-
1
y1
=
np
.
random
.
randn
(
50
)
+
1
trace0
=
go
.
Box
(
y
=
y0
)
trace1
=
go
.
Box
(
y
=
y1
)
data
=
[
trace0
,
trace1
]
py
.
iplot
(
data
)
Out[22]:
In [9]:
import
plotly.plotly
as
py
import
plotly.graph_objs
as
go
x_data