import
plotly.plotly
as
py
import
plotly.graph_objs
as
go
x_data
=
[
'Carmelo Anthony'
,
'Dwyane Wade'
,
'Deron Williams'
,
'Brook Lopez'
,
'Damian Lillard'
,
'David West'
,]
y0
=
np
.
random
.
randn
(
50
)
-
1
y1
=
np
.
random
.
randn
(
50
)
+
1
y2
=
np
.
random
.
randn
(
50
)
y3
=
np
.
random
.
randn
(
50
)
+
2
y4
=
np
.
random
.
randn
(
50
)
-
2
y5
=
np
.
random
.
randn
(
50
)
+
3
y_data
=
[
y0
,
y1
,
y2
,
y3
,
y4
,
y5
]
colors
=
[
'rgba(93, 164, 214, 0.5)'
,
'rgba(255, 144, 14, 0.5)'
,
'rgba(44, 160, 101, 0.5)'
,
'rgba(255, 65, 54, 0.5)'
,
'rgba(207, 114, 255, 0.5)'
,
'rgba(127, 96, 0, 0.5)'
]
traces
=
[]
for
xd
,
yd
,
cls
in
zip
(
x_data
,
y_data
,
colors
):
traces
.
append
(
go
.
Box
(
y
=
yd
,
name
=
xd
,
boxpoints
=
'all'
,
jitter
=
0.5
,
whiskerwidth
=
0.2
,
fillcolor
=
cls
,
marker
=
dict
(
size
=
2
,
),
line
=
dict
(
width
=
1
),
))
layout
=
go
.
Layout
(
title
=
'Points Scored by the Top 9 Scoring NBA Players in 2012'
,
yaxis
=
dict
(
autorange
=
True
,
showgrid
=
True
,
zeroline
=
True
,
dtick
=
5
,
gridcolor
=
'rgb(255, 255, 255)'
,
gridwidth
=
1
,
zerolinecolor
=
'rgb(255, 255, 255)'
,
zerolinewidth
=
2
,
),
margin
=
dict
(
l
=
40
,
r
=
30
,
b
=
80
,
t
=
100
,
),
paper_bgcolor
=
'rgb(243, 243, 243)'
,
plot_bgcolor
=
'rgb(243, 243, 243)'
,
showlegend
=
False
)
fig
=
go
.
Figure
(
data
=
traces
,
layout
=
layout
)
py
.
iplot
(
fig
)