I am reading data from a text file but when I do so, I need to multiple this values like 3*sqrt(col1)
= x1.append(3*math.sqrt(float(p[1])))
in plot function. How can I multiple column number data before plotting? For example, I will multiple col3 data by 3*sqrt(col3) and after plot that data.
#-------input.dat---------
# x y z
# col 1 col 2 col 3
# 3 5 5
# 5 6 4
# 7 7 3
import matplotlib.pyplot as plt
import numpy as np
import pylab as pl
import math
data = open('input.dat')
lines = data.readlines()
data.close()
x1=[]
y1=[]
z1=[]
plt.plot(1)
for line in lines[2:]:
p= line.split()
x1.append(3*math.sqrt(float(p[1])))
y1.append(3*math.sqrt(float(p[2])))
z1.append(3*math.sqrt(float(p[3])))
x=np.array(x1)
y=np.array(y1)
z=np.array(z1)
plt.subplot(311)
plt.plot(x,'b',label=" X figure ")
plt.subplot(312)
plt.plot(y,'r',label=" Y figure ")
plt.subplot(313)
plt.plot(x,z,'g',label=" X,Z figure ")
plt.show()