-
Notifications
You must be signed in to change notification settings - Fork 13
/
figure.py
88 lines (70 loc) · 2.32 KB
/
figure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# ==============================================================
# Author: Rodolfo Ferro
# Twitter: @rodo_ferro
#
# ABOUT COPYING OR USING PARTIAL INFORMATION:
# This script has been originally created by Rodolfo Ferro.
# Any explicit usage of this script or its contents is granted
# according to the license provided and its conditions.
# ==============================================================
# -*- coding: utf-8 -*-
import plotly.graph_objs as go
def plotly_figure_1(data):
"""Creates a nice figure."""
t1_box = go.Box(
name='Largo del sépalo (cm)',
y=data['sepal length (cm)'],
marker={'color': 'rgba(160,160,50,0.7)'}
)
t2_box = go.Box(
name='Ancho del sépalo (cm)',
y=data['sepal width (cm)'],
marker={'color': 'rgba(50,160,150,0.7)'}
)
t3_box = go.Box(
name='Largo del pétalo (cm)',
y=data['petal length (cm)'],
marker={'color': 'rgba(160,60,150,0.7)'}
)
t4_box = go.Box(
name='Ancho del pétalo (cm)',
y=data['petal width (cm)'],
marker={'color': 'rgba(150,160,150,0.7)'}
)
fig_box = [t1_box, t2_box, t3_box, t4_box]
return fig_box
def plotly_figure_2(data):
"""Creates a nice figure."""
# Iris-setosa
trace_setosa = go.Scatter3d(
x=data['sepal length (cm)'][:50],
y=data['sepal width (cm)'][:50],
z=data['petal length (cm)'][:50],
mode='markers',
opacity=0.7,
name="Iris-setosa",
marker={'size': 5, 'color': 'rgba(255,102, 255,0.8)'}
)
# Iris-versicolor
trace_versicolor = go.Scatter3d(
x=data['sepal length (cm)'][50:100],
y=data['sepal width (cm)'][50:100],
z=data['petal length (cm)'][50:100],
mode='markers',
opacity=0.7,
name="Iris-versicolor",
marker={'size': 5, 'color': 'rgba(102, 255, 51, 0.8)'}
)
# Iris-virginica
trace_virginica = go.Scatter3d(
x=data['sepal length (cm)'][100:],
y=data['sepal width (cm)'][100:],
z=data['petal length (cm)'][100:],
mode='markers',
opacity=0.7,
name="Iris-virginica",
marker={'size': 5, 'color': 'rgba(51, 102, 255, 0.8)'}
)
list_3d = [trace_setosa, trace_versicolor, trace_virginica]
fig_3d = go.Figure(data=list_3d)
return fig_3d