from sklearn.datasets import fetch_california_housing
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
%matplotlib inline
housing = fetch_california_housing()
print(housing)
x_axis = housing.data
y_axis = housing.target
style.use('ggplot')
plt.figure(figsize=(7,7))
plt.hist(y_axis, bins=50)
plt.xlabel('price in 1000s USD')
plt.ylabel('number of houses')
plt.show()
# plot scatter plot
style.use('ggplot')
plt.figure(figsize=(7,7))
plt.scatter(housing.data[:,2],housing.target)
plt.ylabel('price in 1000s')
plt.xlabel('number of houses')
plt.show()
# heatmaps
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
flightd = sns.load_dataset('flights')
flightd.head()
flightd = flightd.pivot('month','year','passengers')
flightd
sns.heatmap(flightd)
# piechart
import matplotlib.pyplot as plt
%matplotlib inline
jobd = ['40','20','17','8','5','10']
# for i in jobd:
# print(type(i))
labels = ['IT', 'Finance', 'Marketing', 'Admin', 'HR', 'Operations']
# explode the ist slice
explode = (0.05,0,0,0,0,0)
plt.pie(jobd, labels=labels, explode=explode)
plt.show()
# error bars
import matplotlib.pyplot as plt
x = range(5)
y = (25, 32, 34, 20, 25)
y_offset = (3, 5, 2, 3, 3)
plt.errorbar(x, y, yerr=y_offset, capsize=3, capthick=2)
plt.show()