# -*- coding:utf-8 -*-
"""
作者:sunli
日期:2022年04月08日9:24
"""
import os
import cv2
import pandas as pd
import numpy as np
import configparser as cp
import matplotlib.pyplot as plt
Label = {1: 'Standing', 2: 'Walking', 3: 'Joging', 4: 'Jumping', 5: 'Stair up ', 6: 'Stair down', 7: 'Stand to sit',
8: 'Siting', 9: 'Sit to stand', 10: 'Lying', 0: 'Falling', 11: 'Car-step in', 12: 'Car-step out'}
def show_data(path, name=None):
'''
show data
:param data: DataFrame
:return:
'''
data = pd.read_csv(path)
num = data.acc_x.size
print(num)
t = data.label
title = Label[t[0]]
x = np.arange(num)
fig = plt.figure(1, figsize=(100, 60))
# 子表1绘制加速度传感器数据
# plt.subplot(2, 1, 1)
plt.title(title)
plt.plot(x, data.acc_x, label='x')
plt.plot(x, data.acc_y, label='y')
plt.plot(x, data.acc_z, label='z')
# 添加解释图标
plt.legend()
# x_flag = np.arange(0, num, num/10)
x_flag = np.arange(0, num + num/10, int(num/10))
print(x_flag)
plt.xticks(x_flag)
if name is None:
plt.show()
else:
plt.savefig(name)
plt.close()
def main():
show_data('D:/Dt/MobiAct_Dataset_v2.0/Data/4_400.csv')
if __name__ == '__main__':
main()