You are on page 1of 1

import xlrd #this is for reading excelfiles

import matplotlib.pyplot as grph

demand_sheet=xlrd.open_workbook('./test.xlsx').sheet_by_index(0)
# ./ => refer current directory.
# sheet_by_index(0) => sheet 0 of the excel workbook.
prices=[]
demands=[]

for row in range(0,7):#(0,7)=(row,coloumn)


price=demand_sheet.cell_value((row+1),0)
demand=demand_sheet.cell_value((row+1),1)
prices.append(price)
demands.append(demand)

grph.plot(prices,demands)
grph.xlabel('price')
grph.ylabel('demand')
grph.xlim(1,10)
grph.show()

You might also like