Week02 DataVisualization
Week02 DataVisualization
Data Storytelling
Dr Yeo Wee Kiang
Overview
• Importance of Data Visualization • Data visualization with Matplotlib and
• Why visualizing data is crucial for data analysis Seaborn
• How data type influences the choice of visualization
• Basic line plots, scatter plots, histograms, box plots, and pair
• Selecting the appropriate visualization type plots
• Principles of effective data visualization • Work with multiple subplots to create complex visualizations
• Clarity, Accuracy, Relevance, Efficiency, Simplicity, and • Galleries of Matplotlib and Seaborn visualizations
Appropriateness
• Aesthetics and Storytelling
• Categorical Data
• Bar Plots/Charts: Categorical data, such as product categories or customer segments, are
often best represented using bar charts. Each category corresponds to a bar, and the height
of the bar represents the frequency or value associated with that category.
• Pie Charts: When you want to show the parts of a whole, like the market share of different
products, a pie chart can be effective.
• Numerical Data or Time-Series Data
• Line Plots/Charts: Numerical data, especially time-series data, is commonly visualized
using line charts. This allows you to track changes over a continuous range, such as stock
prices over time.
• Scatter Plots: When you need to explore relationships between two numerical variables,
scatter plots help identify correlations or patterns. For instance, you can use them to analyse
the relationship between a person's age and income.
• Multivariate Data
• Heatmaps: For multivariate data, where relationships between multiple variables need to be
explored simultaneously, heatmaps are valuable. They use colour intensity to represent the
strength or magnitude of relationships between variables.
• Parallel Coordinates: In cases where there are many variables to compare, parallel
coordinates plots can be used to visualize multivariate data effectively.
• Text Data
• Word Clouds: When dealing with text data, such as word frequency in a document or
sentiment analysis results, word clouds provide a visually engaging way to highlight the
most frequently occurring words.
• Hierarchical Data
• Tree Maps: When dealing with hierarchical data structures, like the organization of a
company, tree maps provide a compact and informative way to display nested categories
and their proportions within larger categories.
• Network Data
• Network Graphs: Data involving relationships between entities, like social networks or
computer networks, can be visualized using network graphs. Nodes represent entities, and
edges represent connections between them..
Distribution
• Definition: Probability of outcome occurrence.
• Represented with:
• Histograms
• Example: Histogram showing the distribution of
exam scores.
• Scatter plots
• Example: Scatter plot can be used to visualize
the distribution of property prices against their
square footage.
Dispersion
• Definition: Spread around central tendency.
• Represented with:
• Boxplots
• Example: In a dataset of employee salaries, a
boxplot can be used to visualize the dispersion
of salaries within the organization.
Image source: [Link]
Comparison
• Definition: Compare multiple variables or categories.
• Represented with:
• Bar charts
• Example: Bar chart comparing revenue between
different product categories.
• Line graphs
• Example: Line graph illustrating the growth trends
of multiple companies.
Relationship
• Definition: Connection between variables.
• Represented with:
• Scatter plots
• Example: Scatter plot showing the relationship
between temperature and ice cream sales.
Composition
• Definition: Display variable composition in absolute
and normalized forms.
• Represented with:
• Stacked bar charts
• Example: Stacked bar chart displaying the
composition of a population by age groups.
• Pie charts
• Example: Pie chart showing the composition of a
budget, e.g., expenses.
• Tree maps
• Example: A tree map visualizes a company's
expense distribution by department, with each
rectangle symbolizing a department's budget
allocation.
Fictional data
Unauthorized distribution or sharing of these materials is strictly prohibited. 16
IS5126 Hands-on with Applied Analytics
• Typography
Maintain consistency in font usage throughout the visualization. Use one or two fonts at most
to avoid visual clutter.
• Choose fonts that are easy to read, even when text size is small. Clarity should always be a priority.
• Use typography to provide context and explanations. Titles, labels, and captions should be informative and clear.
• Experiment with font size and weight to guide the viewer's attention. Larger, bold text can draw attention to key points
or insights
Unauthorized distribution or sharing of these materials is strictly prohibited. 17
IS5126 Hands-on with Applied Analytics
• The narrative
• Your narrative is the heart of the data story. It should be clear, concise, and engaging. Create a story that guides your
audience through the data's insights, making complex information easy to understand and relate to.
• Visual elements
• Visuals play an important role in data storytelling. They should complement your narrative, making complex data more
accessible. Use clear and visually appealing charts, graphs, and images to enhance the story's impact.
• Contextual information
• Providing context is essential to help your audience understand the significance of the data. Include definitions,
explanations, and historical context as needed. This background information ensures that your audience understands
the story's relevance.
• Call to action
• The call to action is what you want the audience to do after they have read your story. It could be to learn more, take
action, or simply think about the issue in a new way.
Unauthorized distribution or sharing of these materials is strictly prohibited. 19
IS5126 Hands-on with Applied Analytics
• Provide explanations: This could include providing background information, explaining the
methodology used to collect the data, or interpreting the results of the data.
• For example, if you are presenting about the quality of healthcare in Singapore, you could explain the different factors
that are used to measure quality, such as patient satisfaction, clinical outcomes, and patient safety.
• Provide historical context: This could include explaining the events that led to the data, or the
changes that have occurred over time.
• For example, you could provide historical context for the number of hospital beds in Singapore by explaining how it has
changed over time, such as due to changes in the population, the healthcare system, or the economy.
"The shortage of hospital beds is a growing problem, and we need to act now to address it.
We can all play a role in making sure that everyone has access to quality healthcare.
[Link]
# Sample data
data = [15, 20, 22, 25, 30, 32, 35, 38, 40, 42, 45, 50, 52, 55]
[Link]('Values')
[Link]('Frequency')
[Link]('Histogram with Matplotlib')
[Link]()
import pandas as pd
import seaborn as sns
import [Link] as plt
# Sample data
data = [15, 20, 22, 25, 30, 32, 35, 38, 40, 42, 45, 50, 52, 55]
[Link]('Values')
[Link]('Frequency')
[Link]('Histogram with Seaborn')
[Link]()
# Sample data
data = {
'Group A': [25, 30, 35, 40, 45, 50, 55, 60, 65, 70],
'Group B': [20, 22, 25, 30, 35, 40, 42, 45, 50, 55]
}
import pandas as pd
import seaborn as sns
import [Link] as plt
# Sample data
data = {
'Group A': [25, 30, 35, 40, 45, 50, 55, 60, 65, 70],
'Group B': [20, 22, 25, 30, 35, 40, 42, 45, 50, 55]
}
# Add an annotation
[Link]('Highlight', xy=(2, 12), xytext=(3, 11),
arrowprops=dict(arrowstyle='->', lw=1.5, color='black'),
bbox=dict(boxstyle='round,pad=0.5', edgecolor='black', facecolor='white'))
# Sample data
data = {'Feature1': [4, 1, 4, 1, 3, 8, 4, 5],
'Feature2': [7, 1, 10, 1, 7, 1, 10, 10],
'Feature3': [7, 3, 5, 5, 3, 1, 3, 3],
'Feature4': [8, 2, 6, 5, 3, 2, 4, 4],
'Feature5': [3, 10, 8, 6, 7, 9, 3, 7],
'Feature6': [1, 4, 7, 9, 2, 2, 1, 3],
'Feature7': [8, 10, 6, 3, 9, 4, 5, 4]}
• [Link]
• [Link]