Matplotlib basics Flashcards

1
Q

“What is a histogram in Matplotlib?”

A

“A histogram is a graphical representation of data distribution using bins.”

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

“How do you create a histogram in Matplotlib?”

A

“Use plt.hist(data, bins=10) where data is a numerical dataset.”

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

“How to change the number of bins in a histogram?”

A

“Use the bins parameter in plt.hist(), e.g., plt.hist(data, bins=20).”

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

“How to normalize a histogram?”

A

“Set density=True in plt.hist(), e.g., plt.hist(data, bins=10, density=True).”

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

“What is a bar chart used for?”

A

“A bar chart represents categorical data using rectangular bars.”

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

“How do you create a vertical bar chart in Matplotlib?”

A

“Use plt.bar(categories, values) where categories is a list of labels and values is their corresponding heights.”

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

“How to create a horizontal bar chart?”

A

“Use plt.barh(categories, values) instead of plt.bar().”

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

“What is a pie chart in Matplotlib?”

A

“A pie chart represents proportions of a whole using slices.”

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

“How do you create a basic pie chart?”

A

“Use plt.pie(sizes, labels=labels) where sizes represents proportions.”

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

“How to add percentage labels to a pie chart?”

A

“Use autopct="%1.1f%%" in plt.pie(), e.g., plt.pie(sizes, labels=labels, autopct="%1.1f%%").”

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

“What is a scatter plot used for?”

A

“A scatter plot is used to visualize relationships between two numerical variables.”

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

“How to create a scatter plot in Matplotlib?”

A

“Use plt.scatter(x, y) where x and y are lists of numerical values.”

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

“How to change the marker style in a scatter plot?”

A

“Use the marker parameter, e.g., plt.scatter(x, y, marker="o").”

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

“How do you create multiple subplots in Matplotlib?”

A

“Use plt.subplots(rows, cols), e.g., fig, ax = plt.subplots(2, 2).”

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

“How to add a title to a Matplotlib plot?”

A

“Use plt.title("Title Here").”

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

“How to add labels to the x-axis and y-axis?”

A

“Use plt.xlabel("X-axis Label") and plt.ylabel("Y-axis Label").”

17
Q

“How to save a Matplotlib figure?”

A

“Use plt.savefig("filename.png") to save the plot as an image file.”