Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Viewing all articles
Browse latest Browse all 9596

Quickly Plot in Python with Text File Values

$
0
0

python has this wonderful command in numpy, np.loadtxt .

In this case, I use np.loadtxt to load a file consisting of several ADC values to do a quick plot for visualization.

import matplotlib.pyplot as plt import numpy as np data = np.loadtxt('/path/to/your/file') # get x-axis bins x_axis = np.arange(data.size) * 960 / data.size #plot time domain plt.plot(data) # plot frequency domain plt.figure() spc = np.fft.fft(data) plt.plot(x_axis, 20*np.log10(abs(spc)))

That’s all. Pretty quick and nifty!


Viewing all articles
Browse latest Browse all 9596

Trending Articles