Friday, 18 May 2018

MATLAB plot of data (spectro) with maximum indicator

load llspectro6.txt
x = llspectro6 (:,1);
y = llspectro6 (:,2);
[Peak, PeakIdx] = findpeaks(y);
plot(x,y, 'cyan', 'Linewidth', 2)
ylabel ('Intensity (Counts)')
xlabel ('Wavelength (nm)')
indexmin = find(min(y) == y);
xmin = x(indexmin);
ymin = y(indexmin);
indexmax = find(max(y) == y);
xmax = x(indexmax);
ymax = y(indexmax);
strmax = ['Maximum = ',num2str(xmax)];
text(xmax,ymax,strmax,'HorizontalAlignment','right');

Friday, 12 January 2018

MATLAB data plotting: x vs y plot and x vs y1,y2,y3 etc. plot in single frame

load plot2.txt
x = plot2 (:,1);
y = plot2 (:,2);
plot(x,y, 'r', 'Linewidth', 2)
title('Magnetization plot of 5x5')
ylabel ('Absolute value of Magnetization |M|')
xlabel ('Temperatuire (T)')


load plot2.txt
load plot2.txt
x = plot2 (:,1);
y1 = plot2 (:,2);
y2 = plot2 (:,3);
y3 = plot2 (:,4);
y4 = plot2 (:,5);
plot(x, y1, 'r', x, y2, 'm', x, y3, 'g', x, y4, 'b', 'Linewidth', 2)
title('Specific heat plot of of four lattice sizes')
ylabel ('Specific heat (Cv)')

xlabel ('Temperatuire (T)')

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()