[英]Logging data obtained from txt file
I'm currently a beginner in Python, and I'm currently working on obtaining data from a txt file and producing a graph for log(x)
vs log(y)
. 我目前是Python的初学者,目前正在致力于从txt文件获取数据并为log(x)
与log(y)
生成图形。
This was the basic code, where it would plot the data from the txt file. 这是基本代码,它将在其中绘制txt文件中的数据。
data = loadtxt ("values.txt", float)
plot(data[:,0],data[:,1])
show()
Graph produced: 产生的图:
However, I want to log both x and y. 但是,我想同时记录x和y。 How do I approach this? 我该如何处理?
Check this out. 看一下这个。
import numpy as np
data = loadtxt ("values.txt", float)
x_data = np.log(data[:,0]) # here we are logging over the whole n-dimensional array
y_data = np.log(data[:,1])
plot(x_data, y_data)
show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.