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)
.
This was the basic code, where it would plot the data from the txt file.
data = loadtxt ("values.txt", float)
plot(data[:,0],data[:,1])
show()
Graph produced:
However, I want to log both x and 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()