0% found this document useful (0 votes)
47 views1 page

CISC 504 Assignment 6

This document imports NumPy and Matplotlib libraries, opens a text file containing x and y values, reads the file line by line splitting and appending values to lists, converts the lists to arrays, plots the x and y arrays, and adds labels and a title to the plot.

Uploaded by

Vatsal Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views1 page

CISC 504 Assignment 6

This document imports NumPy and Matplotlib libraries, opens a text file containing x and y values, reads the file line by line splitting and appending values to lists, converts the lists to arrays, plots the x and y arrays, and adds labels and a title to the plot.

Uploaded by

Vatsal Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

"importing numpy to convert list to array"

import numpy as np
"importing pyplot to plot x, y"
import matplotlib.pyplot as plt
"opening file in read mode"
f=open("xy.txt","r");
"reading all lines"
lines=f.readlines();
"creating empty lists for x, y"
x=list();
y=list();
"for each line "
for line in lines:
"split the line into words"
words=line.split(" ");
"word it to float and append to x"
x.append(float(words[0]));
"word it to float and append to y"
y.append(float(words[1]));
"converting list to array"
x=np.array(x);
y=np.array(y);
"closing file"
f.close
"plottting x,y
plt.plot(x,y)

plt.xlabel('x-axis');
plt.ylabel('y-axis');
plt.title('exponential equation')

You might also like