Seaborn Scatterplot

Seaborn Scatterplot

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]:
['FacetGrid',
 'JointGrid',
 'PairGrid',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 '__version__',
 '_compat',
 '_decorators',
 '_docstrings',
 '_oldcore',
 '_orig_rc_params',
 '_statistics',
 'algorithms',
 'axes_style',
 'axisgrid',
 'barplot',
 'blend_palette',
 'boxenplot',
 'boxplot',
 'categorical',
 'catplot',
 'choose_colorbrewer_palette',
 'choose_cubehelix_palette',
 'choose_dark_palette',
 'choose_diverging_palette',
 'choose_light_palette',
 'clustermap',
 'cm',
 'color_palette',
 'colors',
 'countplot',
 'crayon_palette',
 'crayons',
 'cubehelix_palette',
 'dark_palette',
 'desaturate',
 'despine',
 'displot',
 'distplot',
 'distributions',
 'diverging_palette',
 'dogplot',
 'ecdfplot',
 'external',
 'get_data_home',
 'get_dataset_names',
 'heatmap',
 'histplot',
 'hls_palette',
 'husl_palette',
 'jointplot',
 'kdeplot',
 'light_palette',
 'lineplot',
 'lmplot',
 'load_dataset',
 'matrix',
 'miscplot',
 'move_legend',
 'mpl',
 'mpl_palette',
 'pairplot',
 'palettes',
 'palplot',
 'plotting_context',
 'pointplot',
 'rcmod',
 'regplot',
 'regression',
 'relational',
 'relplot',
 'reset_defaults',
 'reset_orig',
 'residplot',
 'rugplot',
 'saturate',
 'scatterplot',
 'set',
 'set_color_codes',
 'set_context',
 'set_hls_values',
 'set_palette',
 'set_style',
 'set_theme',
 'stripplot',
 'swarmplot',
 'utils',
 'violinplot',
 'widgets',
 'xkcd_palette',
 'xkcd_rgb']

View available datasets

In [4]:
sns.get_dataset_names()
Out[4]:
['anagrams',
 'anscombe',
 'attention',
 'brain_networks',
 'car_crashes',
 'diamonds',
 'dots',
 'dowjones',
 'exercise',
 'flights',
 'fmri',
 'geyser',
 'glue',
 'healthexp',
 'iris',
 'mpg',
 'penguins',
 'planets',
 'seaice',
 'taxis',
 'tips',
 'titanic']

Load the dataset

In [5]:
tips = sns.load_dataset("tips")
tips
Out[5]:
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun Dinner 4
... ... ... ... ... ... ... ...
239 29.03 5.92 Male No Sat Dinner 3
240 27.18 2.00 Female Yes Sat Dinner 2
241 22.67 2.00 Male Yes Sat Dinner 2
242 17.82 1.75 Male No Sat Dinner 2
243 18.78 3.00 Female No Thur Dinner 2

244 rows × 7 columns

Scatter plot

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

Machine Learning

  1. Deal Banking Marketing Campaign Dataset With Machine Learning

TensorFlow

  1. Difference Between Scalar, Vector, Matrix and Tensor
  2. TensorFlow Deep Learning Model With IRIS Dataset
  3. Sequence to Sequence Learning With Neural Networks To Perform Number Addition
  4. Image Classification Model MobileNet V2 from TensorFlow Hub
  5. Step by Step Intent Recognition With BERT
  6. Sentiment Analysis for Hotel Reviews With NLTK and Keras
  7. Simple Sequence Prediction With LSTM
  8. Image Classification With ResNet50 Model
  9. Predict Amazon Inc Stock Price with Machine Learning
  10. Predict Diabetes With Machine Learning Algorithms
  11. TensorFlow Build Custom Convolutional Neural Network With MNIST Dataset
  12. Deal Banking Marketing Campaign Dataset With Machine Learning

PySpark

  1. How to Parallelize and Distribute Collection in PySpark
  2. Role of StringIndexer and Pipelines in PySpark ML Feature - Part 1
  3. Role of OneHotEncoder and Pipelines in PySpark ML Feature - Part 2
  4. Feature Transformer VectorAssembler in PySpark ML Feature - Part 3
  5. Logistic Regression in PySpark (ML Feature) with Breast Cancer Data Set

PyTorch

  1. Build the Neural Network with PyTorch
  2. Image Classification with PyTorch
  3. Twitter Sentiment Classification In PyTorch
  4. Training an Image Classifier in Pytorch

Natural Language Processing

  1. Spelling Correction Of The Text Data In Natural Language Processing
  2. Handling Text For Machine Learning
  3. Extracting Text From PDF File in Python Using PyPDF2
  4. How to Collect Data Using Twitter API V2 For Natural Language Processing
  5. Converting Text to Features in Natural Language Processing
  6. Extract A Noun Phrase For A Sentence In Natural Language Processing