#!/usr/bin/python # -*-coding: utf-8 -*- import ctypes from matplotlib import pyplot as plt right_pos = (ctypes.c_int * 3)() left_pos = (ctypes.c_int * 3)() right_att = (ctypes.c_int * 3)() left_att = (ctypes.c_int * 3)() left_foot_pos = (ctypes.c_float * 3)() right_foot_pos = (ctypes.c_float * 3)() left_mag_list = [] right_mag_list = [] down_list = [] if __name__ == '__main__': lib = ctypes.cdll.LoadLibrary("D:\Vs_projecct\gameDLL\gameDLL\\x64\Debug\gameDLL.DLL") fig, ax = plt.subplots() with open("F:\work\matlab\手机数据显示\\ios_run_1641979704.txt") as f: for line in f.readlines(): line = line.strip('\n') data_str = line.split(',') data_int = list(map(int, data_str)) right_mag_list.append(data_int[9:11]) left_mag_list.append( data_int[21:23]) print([x[0] for x in right_mag_list]) ax.plot([x[0] for x in right_mag_list], label = 'right_front_mag') ax.plot([x[0] for x in left_mag_list], label = 'left_front_mag') ax.plot([x[1] for x in right_mag_list], label = 'right_back_mag') ax.plot([x[1] for x in left_mag_list], label = 'left_back_mag') ax.plot(down_list, label = 'down') ax.legend() plt.grid() plt.show()