-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw_in_2d.py
77 lines (54 loc) · 2.12 KB
/
draw_in_2d.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
"""Use matplotlib to draw in 2d the stats in stats/stats CSV file.
Will draw edge reduction function to number of nodes,
and edge reduction function to graph density,
one time for each case (made by powergrasp/powergraph and fullcomress),
then will show the exact same graphs, but with the diff between the two methods.
Accept one CLI argument : the name of the file containing the data.
If you get this error, it's because matplotlib is not up to date:
AttributeError: module 'matplotlib.cm' has no attribute 'plasma'
"""
import sys
import pandas
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np
import methods
DEFAULT_IN_DATA = 'output.csv'
COLORS = [cm.plasma, cm.rainbow]
# COLORS = [cm.seismic, cm.spring, cm.summer]
def plot_multiple_x(xss:iter, ys, xlabels:iter, ylabel):
# fig = plt.figure()
# Plot the surface.
for xs, cmap, xlabel in zip(xss, COLORS, xlabels):
fig = plt.figure()
fig.plot(xs, ys)
ax = fig.gca()
surf = ax.plot_surface(xs, ys, cmap=cmap,
linewidth=10, antialiased=True,
ymin=ys.min(), ymax=ys.max())
# Customize the z axis.
ax.set_ylim(ys.min(), ys.max())
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
# Add a color bar which maps values to colors.
# plt.pcolor(xs, ys, zs, vmin=0.2)
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
import csv
import pandas as pd
file_to_open = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_IN_DATA
print('INFILE:', file_to_open)
df = pd.read_csv(file_to_open, index_col=False)
print(df)
ax = None
for density in (0.4,):
dfd = df.loc[df['context density'] == density]
method_fields = (name + ' time' for name in methods.METHOD_NAMES)
# plt.rcParams['axes.labelsize'] = 20
for method_field in method_fields:
ax = dfd.plot(x='context size', y=method_field, ax=ax)
ax.set_xlabel('context size', fontsize=30)
ax.set_ylabel('runtime', fontsize=30)
plt.show()