In [2]:
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
In [3]:
dir(sns)
Out[3]:
In [4]:
sns.get_dataset_names()
Out[4]:
In [5]:
tips = sns.load_dataset("tips")
tips
Out[5]:
In [8]:
sns.set(color_codes=True)
sns.scatterplot(x = "total_bill", y = "tip", data = tips)
plt.show()
In [9]:
sns.scatterplot(x = tips["total_bill"], y = tips["tip"])
plt.show()
In [10]:
ax = sns.scatterplot(x = "total_bill", y = "tip", data = tips, hue = 'sex')
plt.show()
In [11]:
ax = sns.scatterplot(x = "total_bill", y = "tip", data = tips, hue = 'sex', palette = 'Accent')
plt.show()
In [12]:
sns.scatterplot(x = "total_bill", y = "tip", data = tips, hue = "sex",
hue_order= ['Male', 'Female'])
plt.show()
In [13]:
sns.scatterplot(x = "total_bill", y = "tip", data = tips, size = 'sex')
plt.show()
In [14]:
sns.scatterplot(x = "total_bill", y = "tip", data = tips, size = 'sex', sizes = (50, 200))
plt.show()
In [15]:
sns.scatterplot(x = "total_bill", y = "tip", data = tips, size = 'sex', style_order=['Male','Female'])
plt.show()
In [16]:
plt.figure(figsize = (12, 8))
sns.scatterplot(x = "total_bill", y = "tip", data = tips, size = 'sex')
plt.title("Scatter Plot of Total bill and Tips", fontsize = 25)
plt.xlabel("Total Bills", fontsize = 20)
plt.ylabel("Tips", fontsize = 20)
plt.show()
In [18]:
plt.figure(figsize = (12, 8))
sns.scatterplot(x = "total_bill", y = "tip", data = tips, size = "day", sizes = (50, 300), alpha = 0.7)
plt.title("Scatter Plot of Total bill and Tips", fontsize = 25)
plt.xlabel("Total Bills", fontsize = 20)
plt.ylabel("Tips", fontsize = 20)
plt.show()
In [20]:
# set background 'darkgrid'
sns.set()
plt.figure(figsize = (16,9)) # figure size in 16:9 ratio
sns.scatterplot(x = "tip", y = "total_bill", data = tips, hue = "sex", palette = "hot",
size = "day", sizes = (50, 300), alpha = 0.7)
plt.title("Scatter Plot of Tip and Total Bill", fontsize = 25) # title of scatter plot
plt.xlabel("Tip", fontsize = 20) # x-axis label
plt.ylabel("Total Bill", fontsize = 20) # y-axis label
plt.show() # show scatter plot