Matplotlib Flashcards

1
Q

Matplotlib

A

• Powerful plotting library for python. It emulates the plotting style of matlab, a proprietary software similar to numpy commonly used in engineering and science.

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

Scatter plot

A

• import matplotlib.pyplot as plt
import numpy as np

x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])
y = np.array([99,86,87,88,111,86,103,87,94,78,77,85,86])

plt. scatter(x, y)
plt. show()

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

Line Plot

A

• plt.plot(ypoints, linestyle = ‘dotted’)

plt.show()

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

Bar Plot

A

• plt.bar(x,y)
plt.show()
• plt.barh(x, y)
plt.show()

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

Histogram

A

• x = np.random.normal(170, 10, 250)

plt. hist(x)
plt. show()

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

Heatmap

A

• Like a 2-D histogram, heatmaps are useful for visually comparing 2-dimensions of data (X and Y axes) versus a metric of interest, shown in color. A common use case is when the metric is correlation, similar to R’s corrplot(). This can be done with plt.imshow(), which takes a matrix of values then represents the matrix visually.

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

Digital Image

A

• The function plt.imshow() can also display a digital image, which is itself a 2-D matrix of Red/Green/Blue (RGB) color values. The size of the matrix is also called the resolution of the image, e.g. 1440 x 1080 (HDTV) or 3840 x 2160 (4K). The higher the resolution, the more pixels are used to store the photo, which allows for storing smoother and/or finer color patterns than with fewer pixels.

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