2020-03-10 03:58:51 +00:00
|
|
|
# Titan Robotics Team 2022: Visualization Module
|
|
|
|
# Written by Arthur Lu & Jacob Levine
|
|
|
|
# Notes:
|
|
|
|
# this should be imported as a python module using 'import visualization'
|
|
|
|
# this should be included in the local directory or environment variable
|
|
|
|
# fancy
|
|
|
|
# setup:
|
|
|
|
|
2020-07-30 19:05:07 +00:00
|
|
|
__version__ = "0.0.1"
|
2020-03-10 03:58:51 +00:00
|
|
|
|
|
|
|
#changelog should be viewed using print(analysis.__changelog__)
|
|
|
|
__changelog__ = """changelog:
|
2020-07-30 19:05:07 +00:00
|
|
|
0.0.1:
|
2020-05-06 03:37:32 +00:00
|
|
|
- added graphhistogram function as a fragment of visualize_pit.py
|
2020-07-30 19:05:07 +00:00
|
|
|
0.0.0:
|
2020-05-01 21:15:07 +00:00
|
|
|
- created visualization.py
|
|
|
|
- added graphloss()
|
|
|
|
- added imports
|
2020-03-10 03:58:51 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = (
|
2020-05-01 21:15:07 +00:00
|
|
|
"Arthur Lu <arthurlu@ttic.edu>,"
|
|
|
|
"Jacob Levine <jlevine@ttic.edu>,"
|
|
|
|
)
|
2020-03-10 03:58:51 +00:00
|
|
|
|
|
|
|
__all__ = [
|
2020-05-01 21:15:07 +00:00
|
|
|
'graphloss',
|
|
|
|
]
|
2020-03-10 03:58:51 +00:00
|
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
2020-05-06 03:37:32 +00:00
|
|
|
import numpy as np
|
2020-03-10 03:58:51 +00:00
|
|
|
|
|
|
|
def graphloss(losses):
|
|
|
|
|
2020-05-01 21:15:07 +00:00
|
|
|
x = range(0, len(losses))
|
|
|
|
plt.plot(x, losses)
|
2020-05-06 03:37:32 +00:00
|
|
|
plt.show()
|
|
|
|
|
|
|
|
def graphhistogram(data, figsize, sharey = True): # expects library with key as variable and contents as occurances
|
|
|
|
|
|
|
|
fig, ax = plt.subplots(1, len(data), sharey=sharey, figsize=figsize)
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
|
|
|
|
for variable in data:
|
|
|
|
|
|
|
|
ax[i].hist(data[variable])
|
|
|
|
ax[i].invert_xaxis()
|
|
|
|
|
|
|
|
ax[i].set_xlabel('Variable')
|
|
|
|
ax[i].set_ylabel('Frequency')
|
|
|
|
ax[i].set_title(variable)
|
|
|
|
|
|
|
|
plt.yticks(np.arange(len(data[variable])))
|
|
|
|
|
|
|
|
i+=1
|
|
|
|
|
2020-05-01 21:15:07 +00:00
|
|
|
plt.show()
|