Data Visualization Assignment
~Sruti Suhasaria
~212PGE020
#Hotel Bookings
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
# data-Hotel_bookings
from google.colab import files
data= files.upload()
import io
df= pd.read_csv(io.BytesIO(data["hotel_bookings.csv"]))
df
#BARPLOT
x="hotel"
y= "lead_time"
plt.bar(x, y, data= df, color= ["red", "green"])
plt.xlabel("Hotels")
plt.ylabel("lead_time")
plt.title("Bar Plot showing lead time of hotels")
#Dashed_Line_Plot
plt.plot(x,y, linestyle="dashed", marker= "o", color= "g", data= df)
plt.xticks(rotation= 25)
plt.xlabel("Hotels")
plt.ylabel("lead")
plt.title("Line Graph")
plt.show()
#3D GRAPH
sns.set(style = "darkgrid")
fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
a = df['lead_time']
b = df['stays_in_weekend_nights']
c = df['adults']
ax.set_xlabel("Time")
ax.set_ylabel("Weekend Nights")
ax.set_zlabel("Adults")
ax.scatter(a, b, c)
plt.show()
#Bar_Plot
sns.set(style= "whitegrid")
sns.barplot(x, y, data=df, palette= "magma")
plt.title("Barplot using Seaborn")
plt.xlabel("Hotels")
plt.ylabel("lead_time")
#Box_Plot
sns.boxplot(x,y, data=df)
plt.title("Boxplot using Seaborn")
plt.xlabel("Hotels")
plt.ylabel("lead_time")
#Box Plot using matplot lib
df.boxplot(column='lead_time',by='arrival_date_year',color='red')
plt.xticks(rotation=90)
plt.xlabel('arrival_date_year')
plt.ylabel('lead_time')
#Violin plot using Matplotlib
plt.violinplot(df['lead_time'])
plt.title('Violin_Plot')
#violin plot using seaborn
sns.violinplot(y='lead_time', data=df,color='pink')
plt.title('Violin_Plot')
#Scatter_Plot
sns.relplot(x, y, data=df, kind="scatter", color= "r")
plt.xlabel("Hotels")
plt.ylabel("lead")
plt.title("Scatter_Plot")
#Heat Map
hm= df.corr()
sns.heatmap(hm, cmap= "Spectral")
plt.title("df.corr()")