import numpy as np import matplotlib.pyplot as plt import pandas as pd azdf = pd.read_csv('azimuth.csv') t = azdf["time"] azimuths = np.deg2rad(azdf["azimuth"]) elevation = -4 d = 1 x = np.array([-d for _ in t]) y = np.sin(azimuths) * np.sqrt(d**2 + np.sin(azimuths)**2) z = np.array([d*np.sin(np.deg2rad(elevation)) for _ in t]) fig = plt.figure() ax_ang = fig.add_subplot() r = np.sqrt(x**2 + y**2 + z**2) theta = np.arccos(np.abs(x) / r) phi = np.arctan2(-z, y) #ax_ang.plot(t, r, label='distance') # ax_ang.plot(np.rad2deg(np.arctan2(t, 1)), np.rad2deg(theta), label='pitch') # ax_ang.plot(np.rad2deg(np.arctan2(t, 1)), np.rad2deg(phi), label='roll') ax_ang.plot(t, np.rad2deg(theta), label='pitch') ax_ang.plot(t, np.rad2deg(phi), label='roll') ax_ang.legend(loc='upper left') ax_ang.set_yticks(np.arange(0, 190, 15)) ax_ang.set_title("Euler angles for gimbal") #ax_ang.set_xticks(np.append(np.arange(-60, 40, 15), [-3, 3])) plt.show()