Seaborn & Plotly: A Visual
Exploration of Data
Welcome! This presentation explores Seaborn and Plotly. Discover the power
of Python for data visualization. We'll cover various chart types and their code.
by Vishant Singh
Introduction: Unveiling the Power of Data
Visualization
Why Visualize Data? Seaborn & Plotly
Gain insights: Quickly understand complex data trends and Seaborn provides high-level interface. Plotly allows interactive,
patterns. web-based visualizations. Both work with Pandas DataFrames.
Improve communication: Effectively convey findings to
diverse audiences. import seaborn as sns
Data visualization: Identify outliers and anomalies for import plotly.express as px
deeper analysis.
Seaborn Essentials: Setting the
Stage for Elegant Plots
Aesthetic Control DataFrame Integration
Customize plot styles, color Seamlessly integrates with
palettes, and fonts to create Pandas DataFrames for easy
visually appealing graphics. data input and manipulation.
Simplified Syntax
Offers a high-level interface, reducing code complexity for common
statistical plots.
Scatter Plots with Seaborn:
Unveiling Relationships
Load Data
1
Import your dataset into a Pandas DataFrame.
Create Plot
2
Use sns.scatterplot() to visualize relationships.
Customize
3 Adjust markers, colors, and labels for clarity and aesthetic
appeal.
import seaborn as sns
import matplotlib.pyplot as plt
sns.scatterplot(x='x_column', y='y_column', data=df)
plt.show()
Bubble Charts with Seaborn:
Adding a Dimension of Insight
1 Set Up Plot
Use scatterplot() with the size parameter.
2 Define Size
Map a third variable to the size of the bubbles.
3 Enhance Appearance
Adjust bubble sizes and transparency for optimal visual
representation.
sns.scatterplot(x='x_column', y='y_column', size='size_column',
data=df, alpha=0.5)
Pie Charts with Seaborn: Visualizing Proportions
Aggregate Data
1
Group data to calculate category sizes.
Create Pie
2
Use matplotlib to create the pie chart with the aggregated data.
Customize
3 Add labels, colors, and explode effects for clarity and visual
impact.
import matplotlib.pyplot as plt
plt.pie(df['category_size'], labels=df['category'])
plt.show()
Gantt Charts with Plotly: Project Management Made
Visual
Create Chart
2 Use
plotly.figure_factory.create_gantt().
Data Prep 1
Format task data (start, end, resource).
Customize
Adjust colors, labels, and add
annotations for enhanced project
3
overview.
import plotly.figure_factory as ff
fig = ff.create_gantt(df, index_col='Resource', show_colorbar=True)
fig.show()
Contour Plots with Plotly: Exploring 3D Data in 2D
Prepare Data
1 Create a grid of x, y, and z values.
Generate Plot
2
Use plotly.graph_objects.Contour() to represent the data in 2D.
Refine Appearance
3 Adjust contour levels, color scales, and labels for optimal data
interpretation.
import plotly.graph_objects as go
fig = go.Figure(data=[go.Contour(z=z_values, x=x_values, y=y_values)])
fig.show()
Sunburst Charts with Plotly:
Hierarchical Data Visualization
Structure Data Create Chart
Organize data into parent-child Use plotly.express.sunburst() to
hierarchies. visualize hierarchical
relationships.
Customize
Refine colors, labels, and levels to highlight key hierarchical structures.
import plotly.express as px
fig = px.sunburst(df, path=['parent', 'child'], values='values')
fig.show()
Polar Charts & Heatmaps with
Plotly: Unique Visualizations
Polar Plots Heatmaps
Visualize data in a circular Display data as a color-coded matrix,
coordinate system, ideal for ideal for showing correlations and
representing angles and magnitudes. patterns in large datasets.
import plotly.express as px
fig = px.line_polar(df, r='radius', theta='angle')
fig.show()
fig = px.imshow(data)
fig.show()