Python Part 5: Matplotlib Flashcards

1
Q

import matplotlib

A

import matplotlib.pyplot as plt

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

Plot a diagram showing points from two arrays, x and y, drawn with a red line and showing the datapoints, with a label.

A

plt.plot(x,y, ‘ro-‘, label = ‘Stevie’)

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

add a legend

A

plt.legend()

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

add a legend in the upper left of a diagram

A

plt.legend(loc = ‘upper left’ )

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

add a title, first plot, with the font size 40

A

plt.title(‘first plot’,fontsize=40)

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

add labels for the x and y axes

A

plt.xlabel(‘x axis’,fontsize=18)
plt.ylabel(‘y axis’)

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

plot a histogram

A

plt.hist(data,30,color=’r’,density=True)

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

plot a pie chart

A

plt.pie(y,labels=dataLabels)

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

Plot a scatterplot

A

x=np.arange(100)
y=4.0-0.02*x+np.random.normal(size=100)

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

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