Chapter03_Plotting Flashcards

1
Q

for what is the function
ax1 = fig.add_subplot(2,2,1)
used? Describe the parameters of the function call

A

used to create subplots in a figure. The parameters are
1. Numbers of rows in the grid
2. Number of columns in the grid
3. The position of the subplot within the grid

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

describe the parameter of the function call plt.plot(rng.standard_normal(50).cumsum(),’k–’)

A
  1. rng.standard_normal(50): generate an array of the cumulative sum of a normal distributed array of 50 elements
  2. ‘k–’ : style of plot line as dashed black line
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
fig = plt.figure()
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,2,3)
rng = np.random.default_rng()
plt.plot(rng.standard_normal(50).cumsum(),'k--')
ax1.hist(rng.standard_normal(100),bins=20,color='k',alpha=0.3)
ax2.scatter(np.arange(30),np.arange(30)+3*rng.standard_normal(30))

Describe the position of each plots:

A

plt.plot(rng.standard_normal(50).cumsum(),'k--') : the dashed line will be ploted at ax3, position 3, left bottom

ax1.hist(rng.standard_normal(100),bins=20,color='k',alpha=0.3) : the histogram will be ploted at position one, left top

ax2.scatter(np.arange(30),np.arange(30)+3*rng.standard_normal(30)) : will be ploted at position 2, right top

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

What is a scatter plot?

A

display individual data points in a two-dimension space, x and y axis.

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

Descibe the parameters of the function call ax2.scatter(np.arange(30),np.arange(30)+3*rng.standard_normal(30))

A
  1. x coordinates as integer numbers from 0 to 29
  2. y coordinates as integer numbers from 0 to 29 summed elementwise by 3 times the elements of an normal distributed array of 30 elements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

readjust the size of a figure plot ‘figure’ to width 20 inches and heigh 40 inches

A

plt.rc(‘figure’, figsize=(20, 40))

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

what does the functiona call do? what is the return? plt.subplots(1,2, sharey=True)

A

returns a figure and list of subplots:
* first parameter number of rows
* second parameter number of columns
* sharey=True : subplots share the same y

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

how to define the x and y axis for plt.plot ?

A

define x and y as list an pass them to plt.plot(x,y)

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

how to create a numpy array from price stock saved in data to store the lowest price up to respective index at each possible index?

A

np.minimum.accumulate(data)

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

what is the type of result of np.where(condition1 & condition2) ?

A

tuple, whereas first element with the indices, for which condition1 & condition2 match

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

what does the function sns.pairplot() do?

A

it creates a matrix of histrograms and scatterplots containing all possible pairs od columns from a given DataFrame

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