-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvisualization.py
More file actions
99 lines (78 loc) · 3.45 KB
/
Copy pathvisualization.py
File metadata and controls
99 lines (78 loc) · 3.45 KB
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
89
90
91
92
93
94
95
96
97
98
# import pandas as pd
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
# import matplotlib as mpl
# import numpy as np
# import seaborn as sns
# #load data
# dataFromCSV = pd.read_csv('stat_train_for_visualization.csv', sep=',')
# print(dataFromCSV.shape)
# fig = plt.figure(figsize=(8, 6))
# t = fig.suptitle('Level of Service and independent variables', fontsize=14)
# ax = fig.add_subplot(111, projection='3d')
# xs = list(dataFromCSV['LevelOfService'])
# ys = list(dataFromCSV['Ped_Lane_Width'])
# zs = list(dataFromCSV['Total_occupancy_ped_Lane'])
# data_points = [(x, y, z) for x, y, z in zip(xs, ys, zs)]
# ss = list(dataFromCSV['Hinderance_bb'])
# colors = ['red' if wt == 'red' else 'yellow' for wt in list(dataFromCSV['Hinderance_pp'])]
# markers = [',' if q == 'high' else 'x' if q == 'medium' else 'o' for q in list(dataFromCSV['Hinderance_bp'])]
# for data, color, size, mark in zip(data_points, colors, ss, markers):
# x, y, z = data
# ax.scatter(x, y, z, alpha=0.4, c=color, edgecolors='none', s=size, marker=mark)
# ax.set_xlabel('LevelOfService')
# ax.set_ylabel('Ped_Lane_Width')
# ax.set_zlabel('Total_occupancy_ped_Lane')
import pandas as pd
import plotly
import plotly.graph_objs as go
#Read cars data from csv
data = pd.read_csv("stat_train.csv")
#Set marker properties
markercolor = data['Ped_Lane_Width']
markersize = data['Hinderance_bp']
#Make Plotly figure
fig1 = go.Scatter3d(x=data['LevelOfService'],
y=data['Total_occupancy_ped_Lane'],
z=data['Hinderance_pp'],
marker=dict(size=markersize,
color=markercolor,
opacity=0.9,
reversescale=True,
colorscale='reds'),
line=dict (width=0.02),
mode='markers')
#Make Plot.ly Layout
mylayout = go.Layout(scene=dict(xaxis=dict( title="LevelOfService"),
yaxis=dict( title="Total_occupancy_ped_Lane"),
zaxis=dict(title="Hinderance_pp")),)
#Plot and save html
plotly.offline.plot({"data": [fig1],
"layout": mylayout},
auto_open=True,
filename=("5DPlot.html"))
# #Set marker properties
# markersize = data['Hinderance_bp']
# markercolor = data['Hinderance_pp']
# markershape = data['Hinderance_bb'].replace("low","square").replace("high","circle")
# #Make Plotly figure
# fig1 = go.Scatter3d(x=data['LevelOfService'],
# y=data['Ped_Lane_Width'],
# z=data['Total_occupancy_ped_Lane'],
# marker=dict(size=markersize,
# color=markercolor,
# symbol=markershape,
# opacity=1.0,
# reversescale=True,
# colorscale='Blues'),
# line=dict (width=0.02),
# mode='markers')
# #Make Plot.ly Layout
# mylayout = go.Layout(scene=dict(xaxis=dict( title="LevelOfService"),
# yaxis=dict( title="Ped_Lane_Width"),
# zaxis=dict(title="Total_occupancy_ped_Lane")),)
# #Plot and save html
# plotly.offline.plot({"data": [fig1],
# "layout": mylayout},
# auto_open=True,
# filename=("6DPlot.html"))