-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplottingmonte.py
More file actions
49 lines (37 loc) · 1.97 KB
/
plottingmonte.py
File metadata and controls
49 lines (37 loc) · 1.97 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
import matplotlib.pyplot as plt
import csv
from mpl_toolkits.mplot3d import Axes3D
# Plotting the results of the monte carlo for determining which wager
def graph():
""" Plotting the results of a csv file for monte carlo example """
with open('MonteCarlo.csv', 'r') as montecarlo:
data = csv.reader(filter(lambda row: row[0] != '#', montecarlo), delimiter=',')
for eachline in data: # filter(lambda row: row[0] != '#' lets the csv reader skip comments
percentROI = float(eachline[0]) # Defining which each variable is in the csv file
wagersizepercent = float(eachline[1])
wagercount = float(eachline[2])
pcolor = eachline[3]
plt.scatter(wagersizepercent, wagercount, color=pcolor)
plt.show()
# graph()
# To make interactive (i.e add axes labels for this particular file) use: import plottingmonte as plotm
# To plot from the python console plotm.graph()
# ------------------------------------------------------------------------------------------------
# Making a 3D plot of the information
# ------------------------------------------------------------------------------------------------
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
def threeDplot():
""" Make a 3D plot """
with open('MonteCarlo.csv', 'r') as montecarlo:
data = csv.reader(filter(lambda row: row[0] != '#', montecarlo), delimiter=',')
for eachline in data: # filter(lambda row: row[0] != '#' lets the csv reader skip comments
percentROI = float(eachline[0]) # Defining which each variable is in the csv file
wagersizepercent = float(eachline[1])
wagercount = float(eachline[2])
pcolor = eachline[3]
ax.scatter(wagersizepercent, wagercount, percentROI, color=pcolor)
ax.set_xlabel('wager percent size')
ax.set_ylabel('wager count')
ax.set_zlabel('Percent ROI')
plt.show()