import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
sr = 2000
ts = 1 / sr
file_name = 'C:/Users/Desktop/test_data/sample_003.csv'
def x_sine():
sample = pd.read_csv(file_name)
array = np.array(sample)
where_are_NaNs = np.isnan(array)
array[where_are_NaNs] = 0
x = array[:, 1]
y = array[:, 2]
z = array[:, 3]
t = np.arange(0, np.size(x)) * ts
ax = np.sin(2 * np.pi * t * x / sr)
f = plt.figure()
plt.title('Sine Wave Test - x-axis' + '\n' + file_name.split('/')[-1])
plt.plot(x, ax)
plt.xlabel('Time')
plt.ylabel('Amplitude = sin(time)')
plt.show()
sample_003.csv enter image description here I want to get a file and draw a sine graph. But when I do this, the graph comes out weird. I don't know what to do. Help me
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.