Data Visualization & Storytelling in Python Flashcards

This covers various data visualization in Python

1
Q

What Python libraries are commonly used for data visualization?

A
  • Matplotlib
  • Seaborn
  • Plotly
  • ggplot
  • Altair

Each library has strengths depending on the use case.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Matplotlib?

A

A low-level visualization library for creating static, animated, and interactive plots.

It provides full control over plot appearance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Seaborn built on?

A

Matplotlib

Seaborn simplifies statistical visualizations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What command in Matplotlib is used to create a basic line plot?

A

plt.plot()

Part of Matplotlib’s pyplot module.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Fill in the blank:

plt.show() is used to ____ in Matplotlib.

A

Display the figure.

Without plt.show(), plots may not render properly in some environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you import Seaborn?

A

import seaborn as sns

The alias sns is commonly used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you load a built-in Seaborn dataset?

A

sns.load_dataset(“dataset_name”)

Example: sns.load_dataset(“iris”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the default style of Seaborn?

A

darkgrid

Seaborn styles improve readability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What function is used to create a histogram in Seaborn?

A

sns.histplot()

Histograms help visualize distributions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you change the figure size in Matplotlib?

A

plt.figure(figsize=(width, height))

Helps with readability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which function is used to create a scatter plot in Matplotlib?

A

plt.scatter(x, y)

Scatter plots show relationships between two numerical variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between sns.histplot() and sns.kdeplot()?

A

histplot() shows bar-like frequency, while kdeplot() smooths it into a curve.

KDE plots estimate probability distributions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you create a box plot in Seaborn?

A

sns.boxplot(x=”column”, data=df)

Box plots show distributions and outliers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does a violin plot add compared to a box plot?

A

It shows kernel density estimation (KDE) along with quartiles.

sns.violinplot() is used for this.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What function is used to create a bar chart in Seaborn?

A

sns.barplot(x=”category”, y=”value”, data=df)

Used for categorical comparisons.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the main advantage of using Plotly over Matplotlib?

A

Plotly supports interactivity.

Good for dashboards and dynamic exploration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Which function in Plotly is used for line plots?

A

px.line(df, x=”column_x”, y=”column_y”)

px is short for plotly.express.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the main difference between sns.barplot() and sns.countplot()?

A

barplot()requires numerical y-values, while countplot() works with categorical counts.

Count plots count occurrences automatically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the purpose of ax.set_title(“Title”) in Matplotlib?

A

Adds a title to the plot.

Helps provide context.

20
Q

How do you change the color palette in Seaborn?

A

sns.set_palette(“color_palette”)

Example: “pastel”, “muted”, “deep”.

21
Q

What argument in Seaborn adjusts transparency?

A

alpha

Example: sns.scatterplot(x, y, alpha=0.5).

22
Q

What does plt.savefig(“plot.png”) do?

A

Saves the plot as an image file.

Supports formats like PNG, JPG, SVG.

23
Q

How do you add labels to the x-axis and y-axis in Matplotlib?

A

plt.xlabel(“X Label”), plt.ylabel(“Y Label”)

Labels are crucial for clarity.

24
Q

What is the advantage of using tight_layout()?

A

Adjusts spacing automatically.

Prevents overlapping labels.

25
What does **plt.legend()** do?
Adds a legend to the plot. ## Footnote Legends help differentiate categories.
26
How do you create a **correlation heatmap in Seaborn**?
sns.heatmap(df.corr(), annot=True, cmap="coolwarm") ## Footnote Heatmaps visualize correlations between variables.
27
What does **hue** do in Seaborn plots?
Adds color differentiation based on a categorical variable. ## Footnote Example: sns.scatterplot(x, y, hue="category", data=df).
28
What function is used for **facet grids** in Seaborn?
sns.FacetGrid() ## Footnote Creates multiple subplots for different categories.
29
What is the best visualization for **time series data**?
**Line plot** ## Footnote sns.lineplot() is commonly used.
30
What are ***"small multiples"*** in data visualization?
Repeating the same chart for different subsets of data. ## Footnote Helps in comparative analysis.
31
How do you rotate **x-axis labels** in Matplotlib?
plt.xticks(rotation=45) ## Footnote Useful when dealing with long category names.
32
What does **plt.subplots()** do?
Creates multiple plots in a single figure. ## Footnote Used for dashboards or comparisons.
33
How do you customize **tick labels** in Matplotlib?
plt.xticks(ticks, labels) ## Footnote Helps improve readability.
34
What does **sns.pairplot(df)** do?
Plots pairwise relationships in the dataset. ## Footnote Great for EDA and correlation analysis.
35
What is a **bubble chart**?
**A scatter plot** where point size represents a third variable. ## Footnote Used in business analytics.
36
What does **plt.grid(True)** do?
Adds gridlines to the plot. ## Footnote Improves readability of values.
37
What is the main use of **plt.errorbar()**?
Adds error bars to a plot. ## Footnote Helps show variability or uncertainty.
38
What function is used to create an **animated** plot in Matplotlib?
**FuncAnimation** ## Footnote Part of the matplotlib.animation module.
39
How do you improve performance for large datasets in Seaborn?
Use **sampling **or reduce **marker sizes**. ## Footnote Plotting large datasets can slow performance.
40
What does **sns.set_style("whitegrid")** do?
Changes background style. ## Footnote "darkgrid", "white", and "ticks" are other options.
41
What are the benefits of **interactive visualizations**?
Allows users to **explore data dynamically**. ## Footnote Used in dashboards and web applications.
42
What is the primary use of **dash** in Python?
Creating interactive web-based visualizations. ## Footnote Built on Plotly.
43
How can you create a **dynamic visualization** in Jupyter Notebook?
Use **%matplotlib notebook** or **plotly**. ## Footnote Enables interactive elements.
44
How do you make a visualization publication-ready?
Adjust font sizes, remove unnecessary elements, use appropriate colors. ## Footnote Helps in professional presentations.
45
# True or False: Good data visualization should prioritize aesthetics over accuracy.
**FALSE** ## Footnote Accuracy is always more important than design.