Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- from matplotlib import pyplot as plt
- import matplotlib
- import pandas as pd
- with open("wiki_et.txt") as gd:
- data = gd.read()
- t = []
- x = []
- y = []
- for line in data.split('\n'):
- try:
- a = float(line.replace('Gaze point: ','').split(', ')[0])
- except:
- continue
- try:
- b = 1-(float(line.replace('Gaze point: ','').split(', ')[1]))
- except:
- continue
- x.append(a)
- y.append(b)
- for i in range(len(x)):
- t.append(i)
- fig, ax = plt.subplots(figsize=(16,9))
- ax.set(xlim=(0, 1), ylim=(0, 1))
- plt.plot(x,y,alpha=0.4,c='r',linewidth=2)
- plt.scatter(x,y,marker='.',s=500,alpha=0.01)
- ###!
- import numpy as np
- import matplotlib
- import matplotlib.pyplot as plt
- x = []
- y = []
- for line in data.split('\n'):
- try:
- a = float(line.replace('Gaze point: ','').split(', ')[0])
- except:
- continue
- try:
- b = 1-(float(line.replace('Gaze point: ','').split(', ')[1]))
- except:
- continue
- x.append(a)
- y.append(b)
- fig,ax = plt.subplots(figsize=(16,9))
- ax.set_xlim(xmin=0, xmax=1)
- # Construct 2D histogram from data using the 'plasma' colormap
- plt.hist2d(
- x,
- y,
- bins=(15,18),
- density=False,
- cmap='YlOrRd',
- cmin=15,
- range=([0,1],[0,1])
- )
- # Plot a colorbar with label.
- cb = plt.colorbar()
- cb.set_label('Number of entries')
- # Plot line
- plt.plot(x,y,alpha=0.4,c='b',linewidth=2)
- # Add title and labels to plot.
- plt.title('Heatmap of gaze data points')
- plt.xlabel('x axis')
- plt.ylabel('y axis')
- # legend
- # Show the plot.
- plt.show()
- 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.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement