Assignment 1.1 - Jupyter Notebook
Assignment 1.1 - Jupyter Notebook
1 - Jupyter Notebook
In [14]: #Simple Bar Graph-A simple bar chart is used to represent data involving only
one variable classified on a spatial, quantitative or temporal basis. In a
simple bar chart, we make bars of equal width but variable length, i.e. the
magnitude of a quantity is represented by the height or length of the bars.
plt.bar(x,y)
plt.title('info')
plt.ylabel('Y axis')
plt.xlabel('X axis')
plt.show()
In [33]: #Line Graph-A line graph, also known as a line chart, is a type of chart used
to visualize the value of something over time.
plt.plot(x,y)
plt.title('info')
plt.ylabel('Y axis')
plt.xlabel('X axis')
plt.show()
In [13]: #Multiple Bar Graph-A multiple bar graph shows the relationship between
different values of data. Each data value is represented by a column in the
graph. In a multiple bar graph, multiple data points for each category of
data are shown with the addition of columns.
plt.bar([2,4,5,6,8,8],[4,8,5,4,3,5],label='Ex one')
plt.bar([2,5,2,2,6,9],[3,5,7,2,0,4],label='Ex two',color='g')
plt.legend()
plt.xlabel('bar number')
plt.ylabel('bar height')
plt.title('info')
plt.show()
population_ages=[22,55,62,45,221,22,34,42,42,4,56,8,78,90]
bins=[0,10,20,30,40,50,60,70,80,90,100,110,120,130]
plt.hist(population_ages,bins,histtype='bar',rwidth=0.8)
plt.xlabel('x')
plt.ylabel('y')
plt.title('Histogrm')
plt.legend()
plt.show()
In [28]: #Scatter Plot-a graph in which the values of two variables are plotted along two axes,
the pattern of the resulting points revealing any correlation present.
x=[1,2,3,4,5,6,7,8]
y=[5,2,4,2,1,4,5,2]
plt.scatter(x,y,label='skitscat',color='k')
plt.xlabel('x')
plt.ylabel('y')
plt.title('scatter plot')
plt.legend()
plt.show()
In [30]: #Pie Plot-A pie chart is a circular statistical graphic, which is divided into
slices to illustrate numerical proportion. In a pie chart, the arc length of
each slice, is proportional to the quantity it represents.
plt.pie(slices,labels=activities,colors=cols,startangle=90,
shadow=True,explode=(0,0.1,0,0),autopct='%1.1f%%')
plt.title('Pie Plot')
plt.show()
import numpy as np
import matplotlib.pyplot as plt
def f(t):
return np.exp(-t)*np.cos(2*np.pi*t)
t1=np.arange(0.0,5.0,0.1)
t2=np.arange(0.0,5.0,0.02)
plt.subplot(211)
plt.plot(t1,f(t1),'bo',t2,f(t2))
plt.subplot(212)
plt.plot(t2,np.cos(2*np.pi*t2))
plt.show()
In [35]: #Box Plot-a simple way of representing statistical data on a plot in which a
rectangle is drawn to represent the second and third quartiles, usually with
a vertical line inside to indicate the median value. The lower and upper
quartiles are shown as horizontal lines either side of the rectangle.
value1 = [82,76,24,40,67,62,75,78,71,32,98,89,78,67,72,82,87,66,56,52]
value2=[62,5,91,25,36,32,96,95,3,90,95,32,27,55,100,15,71,11,37,21]
value3=[23,89,12,78,72,89,25,69,68,86,19,49,15,16,16,75,65,31,25,52]
value4=[59,73,70,16,81,61,88,98,10,87,29,72,16,23,72,88,78,99,75,30]
box_plot_data=[value1,value2,value3,value4]
plt.boxplot(box_plot_data,patch_artist=True,labels=['course1','course2','course3','course4'])
plt.show()
In [37]: #Frequency Density Curve-A density curve is a graph that shows probability.
The area under the density curve is equal to 100 percent of all probabilities
# libraries
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import kde
# create data
x = np.random.normal(size=500)
y = x * 3 + np.random.normal(size=500)
# Evaluate a gaussian kde on a regular grid of nbins x nbins over data extents
nbins=300
k = kde.gaussian_kde([x,y])
xi, yi = np.mgrid[x.min():x.max():nbins*1j, y.min():y.max():nbins*1j]
zi = k(np.vstack([xi.flatten(), yi.flatten()]))
In [ ]: