Sunday 24 December 2017

data plotting scatter x vs y in Matlab

load plot2.txt
>> x = plot2 (:,1);
>> y = plot2 (:,2);
>> plot(x,y)
title(' I (V) curve of Blue LED at 620 Ohm')
xlabel ('V measured (V)')
ylabel ('I (mA)')

Wednesday 8 November 2017

plotting without log scale from ascii data: in python (matplotlib)

# Need to import the plotting package:
import matplotlib.pyplot as plt
import numpy as np

# Read the file.
f2 = open("I-V.dat")
# read the whole file into a single variable, which is a list of every row of the file.
lines = f2.readlines()
f2.close()

# initialize some variable to be lists:
x1 = []
y1 = []

# scan the rows of the file stored in lines, and put the values into some variables:
for line in lines:
    p = line.split()
    x1.append(float(p[0]))
    y1.append(float(p[1]))
  
xv = np.array(x1)
yv = np.array(y1)


# now, plot the data:
plt.plot(xv,yv)

plt.legend(["Current (I)"])

plt.show()

plotting data from ascii: two columns and using log scale

# Need to import the plotting package:
import matplotlib.pyplot as plt
import numpy as np

# Read the file.
f2 = open("I-Z.dat")
# read the whole file into a single variable, which is a list of every row of the file.

lines = f2.readlines()
f2.close()

# initialize some variable to be lists:
x1 = []
y1 = []

# scan the rows of the file stored in lines, and put the values into some variables:
for line in lines:
    p = line.split()
    x1.append(float(p[0]))
    y1.append(float(p[1]))
  
xv = np.array(x1)
yv = np.array(y1)



# now, plot the data:

plt.ylabel('Tunnel Current (A)')
plt.xlabel('Voltage (V)')
plt.title('Plot of I-V curve')
plt.plot(-xv,yv)
plt.yscale('log')
plt.grid(True)

plt.legend(["Current (I)"])

plt.show()