print("# =================================================================")
print("# Excercise 4")
print("# -----------------------------------------------------------------")

#E.1: Write a script to
#i. Sum all the items in a array (use random number generator and multiply it by 100, create a vector with the size 200).
#ii. Get the largest number and smallest number with the indexing of it.
#iii. plot the following vector and check your min and max value that you ﬁnd in section i.

import matplotlib.pyplot as plt
import numpy as np
x = np.random.choice(range(1000), 200, replace=False)
print("Random Numbers are : \n", x)
print("The size of the vector is : ", np.size(x))

y = x * 100
print("Random Numbers after Multiplication: ", y)

z = np.sort(y)
print("Random Numbers after sorting: ", z)
print("The largest number of an array: ", z[-1])
print("The smallest number of an array: ", z[0])

plt.plot(y)
plt.title("Plot of Random Numbers")
plt.plot(z)
plt.title("Plot of Random Numbers after sort")

plt.show()

print("Min of Array: ", np.min(z))
print("Max of Array: ", np.max(z))


#E.2: Plot the following functions x, sin(x), ex and log(x) over the interval 1 < x < 6 with the step size of 0.1.
# (Put the title x axis label and y axis label for each plot)
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 6, 0.1)
plt.title('X Function')
plt.xlabel('X - x values from 0 to 6')
plt.ylabel('Y - y (x)')
plt.plot(x)
plt.show()

y = np.sin(x)
plt.title('Sin Function')
plt.xlabel('X - x values from 0 to 6')
plt.ylabel('Y - sin(x))')
plt.plot(x,y)
plt.show()

y = np.exp(x)
plt.title('Exponential Function')
plt.xlabel('X - x values from 0 to 6')
plt.ylabel('Y - exp(x))')
plt.plot(x,y)
plt.show()

y = np.log(x)
plt.title('Logrithmic Function')
plt.xlabel('X - x values from 0 to 6')
plt.ylabel('Y - exp(x))')
plt.plot(x,y)
plt.show()

#E.3: Generate the random gaussian numbers with zero mean and variance of 1 called it vector x,
#generate the random uniform numbers with zero mean and variance of 1 called it vector y

#i. Compute the mean and standard deviation of x and y.
#ii. Plot the histogram of x andy, increase the number of bins to get more resulting.
#Explain what information you get from the histogram(Put the title x axis label and y axis label for each plot)

import matplotlib.pyplot as plt
import numpy as np

# 1D Array - Gaussian Distribution
mean = 0
std = 0.1
array = np.random.normal(0, 0.1, 10000)
print("Mean of Gausian Distribution: \n", np.mean(array))
print()
print("Standard Deviation  of Gausian Distribution: \n", np.std(array))
print()
print("1D Array filled with random values as per gaussian distribution : \n", array)
print()
count, bins, ignored = plt.hist(array, 30, density=True)
plt.plot(bins, 1 / (std * np.sqrt(2 * np.pi)) *
          np.exp(- (bins - mean) ** 2 / (2 * std ** 2)),
          linewidth=2, color='r')
plt.title('Gaussian Distribution')
plt.xlabel('X - axis')
plt.ylabel('Y - axis')
plt.show()

# 1D Array - constructed Randomly
random_array = np.random.rand(5)
print("1D Array filled with random values : \n", random_array)
print()
print("Mean of random uniform numbers: \n", np.mean(random_array))
print()
print("Standard Deviation  of random uniform numbers: \n", np.std(random_array))
print()
plt.title('Random Distribution')
plt.xlabel('X - axis')
plt.ylabel('Y - axis')
plt.plot(random_array)
plt.show()

'''
PLOT - 1
clearly shows Gaussian Distribution, as it is being created from the values generated through random.normal() method 
thus following Gaussian Distribution.
PLOT - 2 
Doesn’t follow any distribution as it is being created from random values generated by random.rand() method.

'''

#E.4: Lets
#A =
# ( 1 2 3
#  4 5 6
#  7 8 9 )
#Answer the following questions (Do not put the digits manually):
#i. Assign vector x to the ﬁrst row of A.
#ii. Assign matrix y to the last 2 rows of A
#iii. Sum the ﬁrst row and add it to the ﬁrst column.
#iv. Compute the norm of x (Euclidian Norm).
#v. Swap the ﬁrst column with the second column and delate the second row.

import numpy as np
A = np.arange(1,10).reshape(3, 3)
print("Vector A ")
print(A[:])

#i. Assign vector x to the ﬁrst row of A.
print("First row of A ")
x = A[0, :]
print(x)

#ii. Assign matrix y to the last 2 rows of A
print("Last 2 rows of A ")
print(A[[1, 2], : ])

#iii. Sum the ﬁrst row and add it to the ﬁrst column.
y = np.sum(x)
print("Sum of First row: ", y)
A[:, 0] = [y, y, y]
print("Sum of first row and adding to first column")
print(A[:])

#iv. Compute the norm of x (Euclidian Norm).
print("Computation of x ", np.linalg.norm(x))

#v. Swap the ﬁrst column with the second column and delete the second row.
print("Swapping of first column with second column")
A[:, [0, 1]] = A[:, [1, 0]]
print(A)
print("Deleting second row \n", np.delete(A, 1, 0))


#E.5: i. Create a vector between 20 and 35, square each elements and sum all the elements of this vector.
#Let
#x =
#( 2 −4 9 −8
# −3 2 −1 0
# 5 4 −3 3)

#ii. Compute the absolute value of x for all the rows and columns separately.
#iii. Compute the square of each elements of x.
#iv. Swap the ﬁrst row by the second row.
#v. Replace the ﬁrst row by zeros and the third row by ones.
#vi. Compute the mean and standard deviation of ﬁrst and third row.
#vii. Sum all the columns and then sum the results.

import numpy as np
# Create a vector between 20 and 35
v = np.arange(20,36)
print("Original vector of array between 20 and 35: \n", v)
#squaring each elements
square = np.square(v)
print("Square Value of array : \n", square)
#summation of elements
print("Sum of all values of array : \n", np.sum(square))

x = np.array([[2, -4, 9, -8], [-3, 2, -1, 0], [5, 4, -3, 3]])
print("Shape of the array: \n", x.shape)
print("Original Values of array x: \n", x)

#ii. Compute the absolute value of x for all the rows and columns separately.
print("Absolute Values of array x: \n", np.absolute(x))

#iii. Compute the square of each elements of x.
print("Square Values of array x: \n", np.square(x))

#iv. Swap the ﬁrst row by the second row.
print("Before swapping of an array x: \n", x)
x[[0,1]] = x[[1,0]]
print("-----After swapping of an array------")
print("Swapping the ﬁrst row by the second row of array x: \n", x)

#v. Replace the ﬁrst row by zeros and the third row by ones.
x[0] = 0
x[2] = 1
print("After Replacing the ﬁrst row by zeros and the third row by ones: \n", x)

#vi. Compute the mean and standard deviation of ﬁrst and third row.
z = x[0, :]
print("Mean of first row : \n", np.mean(z))
print("Standard Deviation of first row: \n", np.std(z))
j = x[2, :]
print("Mean of third row : \n", np.mean(j))
print("Standard Deviation of third row: \n", np.std(j))

#vii. Sum all the columns and then sum the results
h = np.sum(x, axis=0)
print("Sum of all columns: \n", h)
print("Result of column:  \n", np.sum(h))

#E.6:
#Write a Python code to show a bar chart using famous languages.
#Languages: Java, Python, PHP, JavaScript, C#, C++
#Usage (Perecent): 22.2, 17.6, 8.8, 8, 7.7, 6.7

import matplotlib.pyplot as plt
x = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++']
popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7]
x_pos = [i for i, _ in enumerate(x)]

plt.bar(x_pos, popularity, color=(0.4, 0.6, 0.8, 1.0), edgecolor='blue')

plt.xlabel("Languages")
plt.ylabel("Usage in Percentage")
plt.title("Famous Programming Language")
plt.xticks(x_pos, x)
plt.show()

#E.7: Write a Python code to create bar plots with error bars on the same plot.
# Put labels above each bar displaying men average (integer value). Sample Date
# Average: 0.14, 0.32, 0.47, 0.38
# STD: 0.23, 0.32, 0.18, 0.46

import numpy as np
import matplotlib.pyplot as plt

men_means, men_std = (0.14, 0.32, 0.47, 0.38), (0.23, 0.32, 0.18, 0.46)

ind = np.arange(len(men_means))  # the x locations for the groups
width = 0.35  # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind - width / 2, men_means, width, yerr=men_std,
                color='SkyBlue', label='Men')

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
ax.legend()


def autolabel(rects, xpos='center'):
    xpos = xpos.lower()  # normalize the case of the parameter
    ha = {'center': 'center', 'right': 'left', 'left': 'right'}
    offset = {'center': 0.5, 'right': 0.57, 'left': 0.43}  # x_txt = x + w*off

    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x() + rect.get_width() * offset[xpos], 2.01 * height,
                '{}'.format(height), ha=ha[xpos], va='bottom')


autolabel(rects1, "left")
plt.show()

#E8
# Write a script to ﬁnd the second largest number in an array (use random number generator) and multiply it by 50

import numpy as np
x = np.random.choice(range(20), 10, replace=False)
print("Random Numbers: ", x)
y = np.sort(x)
print("Random Numbers after sorting: ", y)
print("The second largest number before multiplication is: ", y[-2])
z = y * 50
print("Random Numbers after Multiplication: ", z)
print("The second largest number after multiplication is: ", z[-2])
print()
print("---------END OF EXCERCISES-4-----------------------")
print("# =================================================================")
print("# CLASS EXCERCISE 4")
print("# -----------------------------------------------------------------")
# =================================================================
# Class_Ex1:
# Write a NumPy code to test if none of the elements of a given
# array is zero.
# ----------------------------------------------------------------
from typing import List

import numpy as np
x = [10, 20, 30, 0]
y = [[10, 20, 30],[0, 1 , 2]]
z = [[True,True],[True, False]]
print(np.all(x))#Test whether all array elements along a given axis evaluate to True.
print(np.all(y))
print(np.all(z))

# =================================================================
# Class_Ex2:
# Write a NumPy code to test if none of the elements of a given
# array is non-zero.
# ----------------------------------------------------------------
import numpy as np
x = [10, 20, 30, 40]
y = [[10, 20, 30],[100, 1 , 2]]
z = [[True,True],[True, True]]
a: List[int] = [10, 20, 30, 0]
print(np.all(x))
print(np.nonzero(x)) #Return the indices of the elements that are non-zero.
print(np.all(y))
print(np.nonzero(y))
print(np.all(z))
print(np.nonzero(z))
print(np.all(a))
print(np.nonzero(a))

# =================================================================
# Class_Ex3:
# Write a NumPy code to test if two arrays are element-wise equal
# within a tolerance.
# ----------------------------------------------------------------

import numpy as np

x1 = [10, 20, 30, 40]
x2 = [10, 20, 30, 40]
print(np.equal(x1,x2))#Return (x1 == x2) element-wise.
print(np.allclose(x1,x2))#Returns True if two arrays are element-wise equal within a tolerance.
print(np.isclose(x1,x2)) #Returns a boolean array where two arrays are element-wise equal within a tolerance.
print()
y1 = [10, 20, 30, 40.0000001]
y2 = [10, 20, -30, 40.0000001]
print(np.equal(y1,y2))
print(np.allclose(y1,y2))
print(np.isclose(y1,y2))
print()
z1 = [[1,2],[1.00000000001,2.00000000001]]
z2 = [[1,2],[1.00000000002,2.00000000003]]
print(np.equal(z1,z2))
print(np.allclose(z1,z2))
print(np.isclose(z1,z2))

# =================================================================
# Class_Ex4:
# Write a NumPy code to create an array with the values
# 1, 8, 130, 10990005 and determine the size of the memory occupied
# by the array.
# ----------------------------------------------------------------

import numpy as np
x = np.array([1, 8, 130, 10990005])
print("Array:", x)
print("Size:", x.size)
print("Itemsize:", x.itemsize)
print("Memory Space Occupation: %d bytes" % (x.size * x.itemsize))

# =================================================================
# Class_Ex5:
# Write a NumPy code to create a array with values ​​ranging from
# 10 to 20 and print all values ​​except the first and last.
# ----------------------------------------------------------------
import numpy as np
x = np.arange(10, 21, 1)
print("Printing all values from 10 to 20")
print(x)
print("Printing all values from 10 to 20 except first and the last ")
print(x[1:-1])

# =================================================================
# Class_Ex6:
# Write a NumPy code to reverse (flip) an array (first element becomes last).
# ----------------------------------------------------------------

import numpy as np
x = np.arange(10, 21, 1)
print("Printing all values from 10 to 20")
print(x)
print("Reversing values of 10 to 20")
print(x[::-1])

# =================================================================
# Class_Ex7:
# Write a NumPy code to create a matrix with 1 on the border and 0 inside.
# ----------------------------------------------------------------

import numpy as np
x = np.ones((4,4))
print("Array with all 1's:" "\n", x,"\n")
print("1 on the border and 0 inside" )
x[1:-1,1:-1] = 0
print(x)


# =================================================================
# Class_Ex8:
# Write a NumPy code to add a border (filled with 0's) around a 3x3
# matrix of one.
# ----------------------------------------------------------------
p = np.ones((1, 1))
q = np.pad(p, pad_width=1, mode='constant', constant_values=0)
print(q)


# =================================================================
# Class_Ex9:
# Write a NumPy code to append values to the end of an array.
# ----------------------------------------------------------------
import numpy as np
x = np.array([1,2,3])
print("Before Appending:",x)
x = np.append(x,[4,5,6])
print("After Appending:", x)

# =================================================================
# Class_E10:
# Write a NumPy code to find the set difference of two arrays.
# The set difference will return the sorted, unique values in array1
# that are not in array2.
# ----------------------------------------------------------------

import numpy as np
x = np.array([1,2,3,2,4,1])
print("Array1:",x)
y = np.array([3,4,5,6])
print("Array2:",y)
z = np.setdiff1d(x,y) #Return the unique values in ar1 that are not in ar2.
print("Unique values in Array1 not in Array2:", z)

# =================================================================
# Class_Ex11:
# Write a NumPy code to construct an array by repeating.
# Sample array: [1, 2, 3, 4, 5]
# ----------------------------------------------------------------
import numpy as np
x = np.array([1,2,3,4,5])
print("Before Repetition:",x)
y = np.repeat(x, [1,2,3,4,5]) #Repeat elements of an array.
print("After Repetition:",y)

# =================================================================
# Class_Ex12:
# Write a NumPy code to get the values and indices of the elements
# that are bigger than 6 in a given array.
# ----------------------------------------------------------------

import numpy as np

temp_array=np.array([3,4,5,6,7,8,1,2,3,4,5,6])
print ("\n\nArray: ",temp_array)
result = np.where(temp_array > 6)

print ("\nValues greater than 6 are: ",temp_array[result],"\nThey are at index (respectively): ",*result)


# =================================================================
# Class_Ex13:
# Write a NumPy program to find the 4th element of a 2 dimensional
# specified array.
# ----------------------------------------------------------------
import numpy as np

temp_array=np.arange(11,20).reshape(3,3)
print ("\n\n2-D Array:\n",temp_array)
print("\n4th element of the array: ",temp_array.flat[3])

# =================================================================
# Class_Ex14:
# Write a NumPy code to get the floor, ceiling and truncated
# values of the elements of an numpy array.
# ----------------------------------------------------------------
import numpy as np

temp_array=np.arange(10,16,0.4)
print ("\n\nArray: ",temp_array)
print("\nFloor values of Array: ",np.floor(temp_array))
print("\nCeiling values of Array: ",np.ceil(temp_array))
print("\nTruncated values of Array: ",np.trunc(temp_array))

# =================================================================
# Class_Ex15:
# Write a NumPy code to compute the factor of a given array by
# Singular Value Decomposition.
# ----------------------------------------------------------------

a = np.array([[1, 0, 5, 7, 2], [0, 0, 3, 0, 0], [6, 7, 0, 9, 0], [0, 2, 0, 0, 0]], dtype=np.float32)
print("Original array:", a)
U, s, V = np.linalg.svd(a, full_matrices=False)
q, r = np.linalg.qr(a)
print("Factor of a given array by SVD:", "U=\n", U, "\ns=\n", s, "\nV=\n", V)

# =================================================================
# Class_Ex16:
# ----------------------------------------------------------------
# Write a NumPy code to compute the eigenvalues and right eigenvectors
# of a given square array.
# ----------------------------------------------------------------

br = np.mat("7 6;1 3")
bp, bq = np.linalg.eig(br)
print("Eigenvalues of the said matrix:: \n", bp)
print("Eigenvectors of the said matrix: \n", bq)

# =================================================================
# Class_Ex17:
# Write a NumPy code to get the dates of yesterday, today and tomorrow.
# ----------------------------------------------------------------

print("Yesterday: ", np.datetime64('today', 'D') - np.timedelta64(1, 'D'))
print("Today: ", np.datetime64('today', 'D'))
print("Tomorrow: ", np.datetime64('today', 'D') + np.timedelta64(1, 'D'))

# =================================================================
# Class_Ex18:
# Write a NumPy code to find the first Monday in June 2021.
# ----------------------------------------------------------------

print("First Monday of June 2021 is: ", np.busday_offset('2021-06', 0, roll='forward', weekmask='Mon'))

# =================================================================
# Class_Ex19:
# Write a NumPy code to find the roots of the following polynomials.
# a) x2 − 3x + 8.
# b) x4 − x3 + -x2 + 1x – 2
# ----------------------------------------------------------------
print("Roots of the first polynomial:", np.roots([1, -3, 8]))
print("Roots of the second polynomial:", np.roots([1, -3, -1, 1, -2]))
# =================================================================
# Class_Ex20:
# Write a NumPy program to calculate mean across dimension, of matrix.
# ----------------------------------------------------------------
import numpy as np

temp_array = np.arange(9).reshape(3,3)
print(temp_array)
print(temp_array.mean(axis=0))
print(temp_array.mean(axis=1))
# =================================================================

# Class_Ex4_2:
# ----------------------------------------------------------------
print("---------Class_Ex4_2:------------")
# =================================================================
# Class_Ex1:
# Class_Ex1:
# Find the slope of the following curve for each of its points
#                  y = np.exp(-x ** 2)
# Then plot it with the original curve np.exp(-X ** 2) in the range
# (-3, 3) with 100 points in the range
# ----------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-3, 3, 100)
y = np.exp(-x**2)
dx = np.diff(x)
dy = np.diff(y)
slope = dy/dx
print(slope)

plt.plot(x,y)
plt.show()

# =================================================================
# Class_Ex2:
# A file contains N columns of values, describing N–1 curves.
# The first column contains the  x coordinates, the second column
# contains the y coordinates of the first curve, the third
# column contains the y coordinates of the second curve, and so on.
#  We want to display those N–1 curves.
# ----------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt

temp_data=np.loadtxt("data2.txt")
for column in temp_data.T:
    plt.plot(temp_data[:,0],column)
plt.show()
# =================================================================
# Class_Ex3:
# Write a efficient code to stack any number of layers of data into
# a bar chart plot.
# Use the following data.
# ----------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt

data = np.random.rand(5,3)
color_list = ['b', 'g', 'r', 'k', 'y']

h_data = np.arange(3)
print(len(data))
temp_bottom=0
for i in range(0,len(data)):
    plt.bar(h_data, data[i], color =color_list[i] , bottom=temp_bottom)
    temp_bottom+=data[i]
plt.show()
# =================================================================
# Class_Ex4:
# Write a Python code to plot couple of lines
# on same plot with suitable legends of each line.
# ----------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt

x_data=np.arange(10)
y1_data=2*x_data+3
y2_data=x_data-4
y3_data=(x_data+10)/3
y4_data=(x_data-9)/2

plt.plot(x_data,y1_data,label=r"$y=2x+3$")
plt.plot(x_data,y2_data,label=r"$y=x-4$")
plt.plot(x_data,y3_data,label=r"$3y=x+10$")
plt.plot(x_data,y4_data,label=r"$2y=x-9$")
plt.legend()
plt.show()
# =================================================================
# Class_Ex5:
# Write a Python code to plot two or more lines with legends,
# different widths and colors.
# ----------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt

x_data=np.arange(10)
y1_data=2*x_data+3
y2_data=x_data-4
y3_data=(x_data+10)/3
y4_data=(x_data-9)/2

plt.plot(x_data,y1_data,label=r"$y=2x+3$",linewidth=4,color='b')
plt.plot(x_data,y2_data,label=r"$y=x-4$",linewidth=3,color='y')
plt.plot(x_data,y3_data,label=r"$3y=x+10$",linewidth=2,color='g')
plt.plot(x_data,y4_data,label=r"$2y=x-9$",linewidth=1,color='r')
plt.legend()
plt.show()
# =================================================================
# Class_Ex6:
# Write a Python code to plot two or more lines and set the line markers.
# ----------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt

x_data=np.arange(10)
y1_data=2*x_data+3
y2_data=x_data-4
y3_data=(x_data+10)/3
y4_data=(x_data-9)/2

plt.plot(x_data,y1_data,label=r"$y=2x+3$",linewidth=4,color='b',marker='o')
plt.plot(x_data,y2_data,label=r"$y=x-4$",linewidth=3,color='y',marker='d')
plt.plot(x_data,y3_data,label=r"$3y=x+10$",linewidth=2,color='g',marker='>')
plt.plot(x_data,y4_data,label=r"$2y=x-9$",linewidth=1,color='r',marker='h')
plt.legend()
plt.show()

# =================================================================
# Class_Ex7:
# Write a Python code to show grid and draw line graph of
# revenue of certain company between November 4, 2017 to November 4, 2018.
# Customized the grid lines with linestyle -, width .6. and color blue.
# ----------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt

x_data = np.arange(np.datetime64('2017-11-04'), np.datetime64('2018-11-05'), np.timedelta64(1,'D'))
y_data=np.random.randint(2500,3500,len(x_data))/10

plt.plot(x_data,y_data,color='maroon')
plt.grid(linestyle='-', linewidth='0.6', color='blue')
plt.xlabel('Date')
plt.ylabel('Revenue (in million $)')
plt.title('ABC Company Revenue')
plt.show()
# =================================================================
# Class_Ex8:
# Write a Python code to create multiple empty plots  in one plot
# (facets)
# ----------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt

fig, axs = plt.subplots(2, 2)
axs[0, 0].set_title("Empty Plot 1")
axs[0, 1].set_title("Empty Plot 2")
axs[1, 0].set_title("Empty Plot 3")
axs[1, 1].set_title("Empty Plot 4")
plt.show()

# =================================================================
# Class_Ex4_3:
# ----------------------------------------------------------------
print("# =================================================================")
print("# CLASS EXCERCISE 4_3")
print("# -----------------------------------------------------------------")
# =================================================================
# Class_Ex1:
# We will be working with a famous titanic data set for these exercises.
# Later on in the Data mining section of the course, we will work  this data,
# and use it to predict survival rates of passengers.
# For now, we'll just focus on the visualization of the data with seaborn:

# use seaboran to load dataset
# ----------------------------------------------------------------
import seaborn as sns
import matplotlib.pyplot as plt

sns.set_style("whitegrid")
titanic = sns.load_dataset("titanic")

# =================================================================
# Class_Ex2:
# Join plot on fare and age
# ----------------------------------------------------------------

sns.jointplot(x="age", y="fare", data=titanic)
plt.show()

# =================================================================
# Class_Ex3:
# Distribution plot on fare with red color and 35 bin
# ----------------------------------------------------------------

sns.distplot(titanic.fare, bins=35, hist=False, color='r')
plt.show()

# =================================================================
# Class_Ex4:
# box plot on class and age
# ----------------------------------------------------------------

sns.boxplot(x="class", y="age", color="b", data=titanic)
plt.show()

# =================================================================
# Class_Ex5:
# swarmplot on class and age
# ----------------------------------------------------------------

sns.swarmplot(x="class", y="age",  data=titanic)
plt.show()

# =================================================================
# Class_Ex6:
# Count plot on sex
# ----------------------------------------------------------------
sns.countplot(x="sex", data=titanic)
plt.show()
'''
# =================================================================
# Class_Ex7:
# plot heatmap
# ----------------------------------------------------------------
heat_data = sns.load_dataset("titanic")
heat_data = titanic.pivot("class", "age", "fare")
sns.heatmap(heat_data, annot=True, fmt="d", linewidths=.5)
plt.show()
'''
# =================================================================
# Class_Ex8:
# Distribution of male and female ages in same grapgh (Facet)
# ----------------------------------------------------------------
sns.distplot(titanic[titanic.sex=='male'].age, bins=20, hist=False, color='r',label="Male")
sns.distplot(titanic[titanic.sex=='female'].age, bins=20, hist=False, color='b',label="Female")
plt.legend()
plt.show()
# =================================================================
# Class_Ex9:
# Explain each graph and describe the results in words
# ----------------------------------------------------------------
'''
Joint plot
count the number of males and females
Distribution plot
Indicates the cabin fare
Box PLot
Indicates the fares break down by deck
Sworm PLot
There are some extreme outliers in the first class distribution
'''





