• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Aug 23rd, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import json
2. from matplotlib import pyplot as plt
3. import matplotlib
4. import pandas as pd
5.
6.
7.
8. with open("wiki_et.txt") as gd:
10.
11. t = []
12. x = []
13. y = []
14.
15. for line in data.split('\n'):
16.     try:
17.         a = float(line.replace('Gaze point: ','').split(', ')[0])
18.     except:
19.         continue
20.
21.     try:
22.         b = 1-(float(line.replace('Gaze point: ','').split(', ')[1]))
23.     except:
24.         continue
25.
26.     x.append(a)
27.     y.append(b)
28.
29. for i in range(len(x)):
30.     t.append(i)
31.
32.
33. fig, ax = plt.subplots(figsize=(16,9))
34. ax.set(xlim=(0, 1), ylim=(0, 1))
35. plt.plot(x,y,alpha=0.4,c='r',linewidth=2)
36. plt.scatter(x,y,marker='.',s=500,alpha=0.01)
37.
38. ###!
39.
40.
41. import numpy as np
42. import matplotlib
43. import matplotlib.pyplot as plt
44.
45.
46.
47.
48. x = []
49. y = []
50.
51. for line in data.split('\n'):
52.     try:
53.         a = float(line.replace('Gaze point: ','').split(', ')[0])
54.     except:
55.         continue
56.
57.     try:
58.         b = 1-(float(line.replace('Gaze point: ','').split(', ')[1]))
59.     except:
60.         continue
61.
62.     x.append(a)
63.     y.append(b)
64.
65.
66.
67.
68.
69. fig,ax = plt.subplots(figsize=(16,9))
70. ax.set_xlim(xmin=0, xmax=1)
71.
72. # Construct 2D histogram from data using the 'plasma' colormap
73. plt.hist2d(
74.     x,
75.     y,
76.     bins=(15,18),
77.     density=False,
78.     cmap='YlOrRd',
79.     cmin=15,
80.     range=([0,1],[0,1])
81. )
82.
83. # Plot a colorbar with label.
84. cb = plt.colorbar()
85. cb.set_label('Number of entries')
86.
87. # Plot line
88. plt.plot(x,y,alpha=0.4,c='b',linewidth=2)
89.
90. # Add title and labels to plot.
91. plt.title('Heatmap of gaze data points')
92. plt.xlabel('x axis')
93. plt.ylabel('y axis')
94.
95. # legend
96.
97.
98. # Show the plot.
99. plt.show()
100.
101.
102. print(f"With {len(x)} coordinates captured and the eye-tracker recording at 90 Hz,\nthe timespan of the recording is around {round((len(x)/90),2)} seconds or {round((len(x)/90/60),2)} minutes.")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top