tra-analysis/analysis-master/analysis/visualization.py

58 lines
1.2 KiB
Python
Raw Normal View History

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:
__version__ = "0.0.1"
2020-03-10 03:58:51 +00:00
#changelog should be viewed using print(analysis.__changelog__)
__changelog__ = """changelog:
0.0.1:
2020-05-06 03:37:32 +00:00
- added graphhistogram function as a fragment of visualize_pit.py
0.0.0:
- created visualization.py
- added graphloss()
- added imports
2020-03-10 03:58:51 +00:00
"""
__author__ = (
"Arthur Lu <arthurlu@ttic.edu>,"
"Jacob Levine <jlevine@ttic.edu>,"
)
2020-03-10 03:58:51 +00:00
__all__ = [
'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):
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
plt.show()