Chapter03_Plotting Flashcards
for what is the function
ax1 = fig.add_subplot(2,2,1)
used? Describe the parameters of the function call
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
describe the parameter of the function call plt.plot(rng.standard_normal(50).cumsum(),’k–’)
- rng.standard_normal(50): generate an array of the cumulative sum of a normal distributed array of 50 elements
- ‘k–’ : style of plot line as dashed black line
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:
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
What is a scatter plot?
display individual data points in a two-dimension space, x and y axis.
Descibe the parameters of the function call ax2.scatter(np.arange(30),np.arange(30)+3*rng.standard_normal(30))
- x coordinates as integer numbers from 0 to 29
- y coordinates as integer numbers from 0 to 29 summed elementwise by 3 times the elements of an normal distributed array of 30 elements
readjust the size of a figure plot ‘figure’ to width 20 inches and heigh 40 inches
plt.rc(‘figure’, figsize=(20, 40))
what does the functiona call do? what is the return? plt.subplots(1,2, sharey=True)
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 to define the x and y axis for plt.plot ?
define x and y as list an pass them to plt.plot(x,y)
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?
np.minimum.accumulate(data)
what is the type of result of np.where(condition1 & condition2) ?
tuple, whereas first element with the indices, for which condition1 & condition2 match
what does the function sns.pairplot() do?
it creates a matrix of histrograms and scatterplots containing all possible pairs od columns from a given DataFrame