Data analytics subject, Slides of Computer science

Python libraries includes pandas, matplotlib, seaborn

Typology: Slides

2025/2026

Available from 06/30/2026

poojitha-chougani
poojitha-chougani 🇮🇳

8 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Seaborn
UNIT-V
Seaborn Department of CSE, School of Engineering, Malla Reddy
University.
UNIT-I
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Data analytics subject and more Slides Computer science in PDF only on Docsity!

Introduction to Seaborn

UNIT-V

Seaborn Department of CSE, School of Engineering, Malla Reddy University.

UNIT-I

08 Middle Level

Language Structured Language Rich Library Speed Memory Management

  1. Introduction to Seaborn
  2. Using Seaborn with Matplotlib
  3. Customizing Seaborn Plots
    • (^) Changing Figure Aesthetic
    • (^) Removal of Spines
    • (^) Changing the figure Size
    • (^) Scaling the plots
    • (^) Setting the Style Temporarily
  4. Color Palette
    • (^) Diverging Color Palette
    • (^) Sequential Color Palette
    • (^) Setting the default Color Palette
  5. Multiple plots with Seaborn
    • (^) Using Matplotlib
    • (^) Using Seaborn Seaborn Department of CSE, School of Engineering, Malla Reddy UNIT-I

08 Middle Level

Language Structured Language Rich Library Speed Memory Management Seaborn has the following dependencies  (^) Python  (^) numpy  (^) scipy  (^) pandas  (^) matplotlib Note: Before using seaborn, first Install all dependencies of seaborn Seaborn Department of CSE, School of Engineering, Malla Reddy UNIT-I

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management

importing seaborn library

import seaborn as sns

loading predefined dataset (iris) by using following syntax

data = sns.load_dataset("iris")

loading user defined dataset using seaborn **dependency

library ( pandas)** data= pd.read_csv(r"C:\Users\RamaraoT\Desktop\new\student.csv")

draw lineplot

sns.lineplot(x,y) Some of the Syntaxes of seaborn : Seaborn Department of CSE, School of Engineering, Malla Reddy UNIT-I

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management Using both Matplotlib and Seaborn together is a very simple process. We just have to invoke the Seaborn Plotting function as normal , and then we can use **Matplotlib customization functions (examples: title,xlabel,ylabel,xlim,ylim and show). Using Seaborn with Matplotlib:

importing packages**

import seaborn as sns import matplotlib.pyplot as plt # loading dataset data = sns.load_dataset("iris") # setting the title using Matplotlib plt.title('Title using Matplotlib Function‘) # draw lineplot sns.lineplot(x="sepal_length", y="sepal_width", data=data) Seaborn Department of CSE, School of Engineering, Malla Reddy UNIT-I

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management Import seaborn as sns https://seaborn.pydata.org/api.html

1. Line plot : sns.lineplot(x,y) https://seaborn.pydata.org/generated/seaborn.lineplot.html#seaborn.lineplot 2. Bar plot : sns. barplot(x,y) https:// seaborn.pydata.org/generated/seaborn.barplot.html#seaborn.barplot 3. Hist plot : sns.histplot(x,y) https:// seaborn.pydata.org/generated/seaborn.histplot.html 4. Scatter plot: sns. Scatterplot (x,y) https:// seaborn.pydata.org/generated/seaborn.scatterplot.html

  1. Boxplot: sns. boxplot (x,y) https:// Seaborn Plots:

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management

Relational plots:

In seaborn 3 types of Relational plots are available.

1. Relplot

2. Scatterplot

3. lineplot

  1. Relplot: Figure-level interface for drawing relational plots onto a FacetGrid. provides access to several different axes-level functions that show the relationship between two variables with semantic mappings of subsets. The kind parameter selects the underlying axes-level function to use: scatterplot() (with kind="scatter"; the default) lineplot() (with kind="line") The relationship between x and y can be shown for different subsets of the data using the hue, size, and style parameters. These parameters control what visual semantics are used to identify the different subsets.

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management

Dataset Description:

Tips dataset is a data frame with 244 rows and 7 variables

which represents some tipping data where one waiter recorded

information about each tip he received over a period of a few

months working in one restaurant. In all the waiter recorded 244

tips.

tips = sns.load_dataset("tips")

tips.head()

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management Seaborn comes with some customized themes and a high-level interface for customizing the looks of the graphs. we can customize the graph according to our own needs. So let’s see the following styling of plots in detail.

  1. Changing Figure Aesthetic
  2. Removal of Spines
  3. Changing the figure Size
  4. Scaling the plots
  5. Setting the Style Temporarily Customizing Seaborn Plots:

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management set_style() method is used to set the aesthetic of the plot. It means it affects things like the color of the axes, whether the grid is active or not. There are five themes available in Seaborn.

  • (^) darkgrid
  • (^) whitegrid
  • (^) dark
  • (^) white
  • (^) ticks Syntax:
  1. Changing Figure Aesthet ic

set_style(‘style_name’)

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management Example: Using the white theme **:

importing packages**

import seaborn as sns import matplotlib.pyplot as plt # loading dataset data = sns.load_dataset("iris") # draw lineplot sns.lineplot(x="sepal_length", y="sepal_width", data=data) # changing the theme to dark sns.set_style(“white") plt.show()

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management Spines are the lines noting the data boundaries and connecting the axis (x-axies and y-axies) tick marks. It can be removed using the despine() method.[ex: despine(left=True) or despine(bottom=True)

  1. Removal of Spines

# importing packages import seaborn as sns import matplotlib.pyplot as plt # loading dataset data = sns.load_dataset("iris") # draw lineplot sns.lineplot(x="sepal_length", y="sepal_width", data=data) # Removing the spines sns.despine() plt.show()

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management It can be done using the set_context() method. It allows us to override default parameters. This affects things like the size of the labels, lines, and other elements of the plot, but not the overall style. The base context is “ notebook ”, and the other contexts are “paper”, “talk”, and “poster”. font_scale sets the font size. https:// seaborn.pydata.org/generated/seaborn.set_context.html#seaborn.set_context

4. Scaling the plots :

# importing packages import seaborn as sns import matplotlib.pyplot as plt # loading dataset data = sns.load_dataset("iris") # Setting the scale of the plot #sns.set_context("paper") sns.set_context("paper",font_scale=2.6) sns.lineplot(x="sepal_length", y="sepal_width", data=data)

08 Middle Level

Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management axes_style() method is used to set the style temporarily. It is used along with the with statement. 5.Setting the Style Temporari ly

# importing packages import seaborn as sns import matplotlib.pyplot as plt # loading dataset data = sns.load_dataset("iris") # draw lineplot sns.lineplot(x="sepal_length", y="sepal_width", data=data) # Setting the style temporarily with sns.axes_style('darkgrid'): sns.lineplot(x="sepal_length", y="sepal_width", data=data)