0% found this document useful (0 votes)
7 views11 pages

Dv.assignment 0

The document provides an overview of various Python libraries for data visualization, including Matplotlib, Seaborn, Pandas, Plotnine, Plotly, Bokeh, Altair, and Folium. Each library is discussed in terms of its introduction, importance, pros, cons, differences from others, and common functions. This summary highlights the unique features and use cases of each library, emphasizing their roles in static, interactive, and geospatial visualizations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

Dv.assignment 0

The document provides an overview of various Python libraries for data visualization, including Matplotlib, Seaborn, Pandas, Plotnine, Plotly, Bokeh, Altair, and Folium. Each library is discussed in terms of its introduction, importance, pros, cons, differences from others, and common functions. This summary highlights the unique features and use cases of each library, emphasizing their roles in static, interactive, and geospatial visualizations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

LAB ASSIGNMENT_0

I. Static and Statistical Visualization.


A. Matplotlib
Introduction
Matplotlib is one of the most important Python libraries for data
visualization because it lets users create static, animated, and
interactive plots in Python. It is widely used in science,
engineering, and data analysis because it gives very fine
control over every part of a graph
Importance in Data Visualization.
Matplotlib is useful when you need complete control over the
appearance of a plot. It can create line charts, bar charts,
scatter plots, histograms, pie charts, and many other graph
types. It is especially good for academic work, reports, and
custom visualizations. Since it is flexible and stable, it is often
the first plotting library learned by Python users.
Pros:
 very flexible, highly customizable, supports many plot
types, and is the foundation for many other Python
visualization tools.
 Easy to customize.
 Supports many chart types.
 Works well with NumPy and Pandas.
 Excellent for publication-quality figures.
Cons:
 it can be hard to learn at first, the syntax is often verbose,
and complex plots may take more code.
 Requires more code.
 Default styles are less attractive.
 Not ideal for highly interactive visualizations.
Difference:
Base library for many visualization packages.
More flexible than Seaborn.
Less interactive than Plotly and Bokeh.
Common Functions
Function
 plot() - Draw line graph
 scatter() - Create scatter plot
 bar() - Draw bar chart
 hist() - Create histogram
 pie() - Draw pie chart
 boxplot() - Create box plot
 xlabel() - Add X-axis label
 ylabel() - Add Y-axis label
 title() - Add graph title
 legend() - Display legend
 grid() - Show grid
 show() - Display plot

B. Seaborn
Introduction:
Seaborn is a high-level statistical visualization library built on
top of Matplotlib. It is designed to make statistical charts easier
to create and more attractive by default. Compared to
Matplotlib, Seaborn usually needs less code and gives better-
looking graphs automatically. It works especially well with
pandas DataFrames.
Importance in Data Visualization:
Seaborn is important because it helps users explore data
patterns, relationships, and distributions quickly. It is commonly
used for heatmaps, box plots, violin plots, pair plots, and
distribution plots. It is very useful in data analysis because it
focuses on statistical graphics rather than basic drawing. For
beginners, it is easier than Matplotlib for many common
visualization tasks.
Pros:
 Easy to use, produces attractive plots by default, and is
great for statistical visualization
 Beautiful default themes.
 Less coding.
 Supports statistical plots.
 Works directly with Pandas.
Cons:
 Less customizable than Matplotlib for very fine control,
and it depends on Matplotlib underneath.
 Less customizable than Matplotlib.
 Depends on Matplotlib.
Difference:
Simpler than Matplotlib.
Better for statistical graphics.
Less interactive than Plotly.
Functions:
 lineplot() - Draw line graph
 scatterplot() - Scatter plot
 barplot() - Bar chart
 histplot() - Histogram
 boxplot() - Box plot
 violinplot() - Violin plot
 heatmap() - Heat map
 pairplot() - Relationship plots
 countplot() - Count categories
 lmplot() - Regression plot

C. Pandas
Introduction:
Pandas is mainly a data analysis library, but it also provides
plotting features through [Link]() and the
[Link] module. Its plotting system is convenient
because it works directly on Series and DataFrames. By default,
pandas uses Matplotlib as the backend for plotting. This makes
it very helpful when you want quick charts from tabular data.
Importance in Data Visualization:
Pandas plotting is useful for fast visual checks of data during
cleaning and analysis. It is simple to use when data is already
stored in a DataFrame. With a single line of code, you can
create line plots, bar charts, histograms, scatter plots, and box
plots. It is not as advanced as dedicated visualization libraries,
but it is very practical for everyday analysis
Pros:
 Quick plotting directly from DataFrames, convenient for
exploratory analysis, and simple for basic charts.
 Very easy to use.
 Integrated with Matplotlib.
 Excellent for data preprocessing.
Cons:
 Limited styling options, and it is not meant for advanced
visualization work.
 Limited chart customization.
 Not suitable for advanced visualization.
Difference:
Focuses on data handling.
Uses Matplotlib internally.
Functions:
 plot() - General chart
 hist() - Histogram
 boxplot() - Box plot
 scatter() - Scatter plot
 bar() - Bar chart
 pie() - Pie chart
 line() - Line chart

D. Plotnine
Introduction:
Plotnine is a Python implementation of the Grammar of
Graphics, similar in style to ggplot2 in R. It lets users build plots
by layering data, aesthetics, and geometric objects. Every plot
begins with ggplot() and can be customized with themes and
layers. This makes Plotnine useful for users who like a
declarative style of plotting.
Importance in Data Visualization:
Plotnine is important for creating clean, structured, and elegant
statistical graphics. It is especially good when you want plots
that follow a consistent grammar-based design. Because of its
layer-based approach, it is easier to build complex plots step by
step. It is often preferred in teaching, research, and
reproducible analysis.
Pros:
 Interactive charts, hover/zoom support, great for
dashboards, and visually appealing output.
 Easy layered graphics.
 Professional-looking charts.
 Similar to ggplot2.
Cons:
 Can be more complex than static libraries, and some users
find the setup and ecosystem confusing.
 Slower than Matplotlib.
 Smaller community.
Difference:
Uses Grammar of Graphics.
Easier for complex statistical plots.
Functions:
 ggplot() - Create plot
 aes() - Map variables
 geom_point() - Scatter plot
 geom_line() - Line plot
 geom_bar() - Bar chart
 geom_histogram() - Histogram
 geom_boxplot() - Box plot
 labs() - Add labels
 theme() - Customize appearance

II. Interactive and Web-Based Visualization


A. Plotly
Introduction:
Plotly is a library for creating interactive visualizations and web-
based graphs in Python. It supports hover information,
zooming, panning, and other interactive features. Plotly is
widely used for dashboards and modern web apps. Its Python
graphing library, [Link], is designed specifically for
interactive visualizations.
Importance in Data Visualization:
Plotly is important because it makes charts more engaging and
user-friendly. It is ideal when users need to explore data
dynamically instead of viewing a static image. Plotly is
commonly used in dashboards, business analytics, and web
applications. It also works well for complex plots like 3D charts,
maps, and animated graphs.
Pros:
 Interactive charts, hover/zoom support, great for
dashboards, and visually appealing output.
 Zoom and hover support.
 Beautiful graphs.
 Export to HTML.
Cons:
 Can be more complex than static libraries, and some users
find the setup and ecosystem confusing.
 Larger file size.
 Slightly slower.
Difference:
More interactive than Matplotlib.
Better dashboards than Seaborn.
Functions:
 [Link]() – creates interactive scatter plots.
 [Link]() – creates interactive line charts.
 [Link]() – creates bar charts.
 [Link]() – creates histograms.
 [Link]() – creates pie charts.
 [Link]() – creates box plots.
 plotly.graph_objects.Figure() – creates custom interactive
figures.
 update_layout() – changes titles, axes, and layout.
 write_html() – saves interactive plots as HTML.

B. Bokeh
Introduction:
Bokeh is a Python library for creating interactive visualizations
in modern web browsers. It is designed for building beautiful
graphics, dashboards, and streaming data applications. Bokeh
lets users create JavaScript-powered visualizations without
writing JavaScript themselves. This makes it a powerful choice
for browser-based analytics.
Importance in Data Visualization:
Bokeh is useful when you want interactive plots that can be
embedded in websites or dashboards. It supports pan, zoom,
hover, and selection tools. It is especially strong for live data
and applications that need browser interaction. Compared with
static libraries, Bokeh is more suitable for web-first data
presentation.
Pros:
 Powerful for browser-based interactivity, good for
dashboards, and supports streaming/live data.
 Web-ready.
 Interactive tools.
Cons:
 The learning curve can be steeper than Seaborn or
Pandas, and simple plots may feel heavier than needed.
 Harder to learn.
 Fewer statistical plots.
Difference:
Better web interaction than Matplotlib.
Functions:
 figure() – creates a plot canvas.
 line() – draws a line chart.
 circle() – draws scatter points.
 vbar() – draws vertical bars.
 hbar() – draws horizontal bars.
 show() – displays the plot.
 output_file() – saves to an HTML file.
 output_notebook() – displays in Jupyter.
 add_tools() – adds interactive tools.

C. Altair
Introduction:
Altair is a declarative visualization library for Python that
focuses on concise, readable code for statistical charts. It is
built around the idea of describing what the visualization should
show, rather than drawing it step by step. Altair is well known
for its clean syntax and strong integration with data analysis
workflows. It is especially useful for exploratory analysis and
interactive charts.
Importance in Data Visualization:
Altair is important because it makes statistical visualization
simple and expressive. Users can create interactive charts with
relatively little code. It is well suited for data exploration, where
clarity and compact syntax matter. Altair also works well when
you want tidy, easy-to-read visual code.
Pros:
 Concise code, declarative style, and strong for exploratory
statistical charts.
 Very clean code.
 Automatic interaction.
 Easy learning.
Cons:
 Not ideal for very large datasets without handling data
limits, and it is less flexible for some custom low-level
control than Matplotlib.
 Limited customization.
 Less suitable for huge datasets.
Difference:
Easier than Bokeh.
Simpler than Plotly.
Functions:
 Chart() – creates a chart object.
 mark_point() – creates scatter plots.
 mark_line() – creates line charts.
 mark_bar() – creates bar charts.
 mark_area() – creates area charts.
 encode() – maps data fields to chart properties.
 interactive() – enables interactivity.
 properties() – sets chart size and title.
 facet() – creates faceted views.

III. Geospatial and Maps


A. Folium
Introduction:
Folium is a Python library for creating interactive maps . It is
built on top of [Link], which is a popular JavaScript mapping
library . Folium allows users to display geographic data on
maps, add markers, popups, heatmaps, and other map layers.
It is especially useful for location-based data analysis.
Importance in Data Visualization:
Folium is important in geospatial visualization because it helps
users visualize data on real maps. It is commonly used for
travel maps, location tracking, regional analysis, and
geographic dashboards. Since it creates interactive web maps,
users can zoom, pan, and click markers easily. It is a practical
choice for mapping tasks in Python.
Pros:
 Excellent for interactive maps, easy to use for geographic
data, and supports markers, popups, and heatmaps.
 Interactive maps.
 Easy to use.
 Uses [Link].
Cons:
 Focused mainly on mapping, so it is not useful for general
charting outside geospatial work.
 Limited advanced GIS features.
 Internet required for map tiles.
Difference:
Specialized for maps.
Unlike Plotly and Matplotlib, it focuses on geographical
visualization.
Functions:
 Map() – creates a map object.
 Marker() – adds a marker to the map.
 Popup() – shows pop-up information.
 CircleMarker() – adds circular markers.
 TileLayer() – changes the map style.
 PolyLine() – draws lines on the map.
 GeoJson() – adds geographic JSON data.
 HeatMap() – shows density on a map.
 save() – saves the map as an HTML file

You might also like