



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Python libraries includes pandas, matplotlib, seaborn
Typology: Slides
1 / 35
This page cannot be seen from the preview
Don't miss anything!




























Seaborn Department of CSE, School of Engineering, Malla Reddy University.
Language Structured Language Rich Library Speed Memory Management
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
Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management
import seaborn as sns
data = sns.load_dataset("iris")
library ( pandas)** data= pd.read_csv(r"C:\Users\RamaraoT\Desktop\new\student.csv")
sns.lineplot(x,y) Some of the Syntaxes of seaborn : Seaborn Department of CSE, School of Engineering, Malla Reddy UNIT-I
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:
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
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
Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management
Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management
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.
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.
Language Structured Language Rich Library Extensible Recursion Pointers Speed Memory Management Example: Using the white theme **:
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()
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)
# 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()
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
# 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)
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)