Plotting the growth curve
You saw in the previous exercise that the confidence interval on the growth curve is very tight. You will explore this graphically here by plotting several bootstrap lines along with the growth curve. You will use the plt.semilogy()
function to make the plot with the y-axis on a log scale. This means that you will need to transform your theoretical linear regression curve for plotting by exponentiating it.
This is a part of the course
“Case Studies in Statistical Thinking”
Exercise instructions
- Plot the data points using
plt.semilogy()
. Thenumpy
arrayst
andbac_area
are again in your namespace. - Use
np.array()
to generate time values for plotting the bootstrap lines. Call thist_bs
. The time should go from 0 to 14 hours. - Write a
for
loop to plot regression lines corresponding to the first 100 pairs bootstrap replicates. Thenumpy
arraysgrowth_rate_bs_reps
andlog_a0_bs_reps
that you computed in the last exercise are in your namespace.- Compute the growth curve by exponentiating the linear regression line using
np.exp()
. - Plot the theoretical line using
plt.semilogy()
with keyword argumentslinewidth=0.5
,alpha=0.05
, andcolor='red'
.
- Compute the growth curve by exponentiating the linear regression line using
- Label the axes and show your plot. Appropriate labels for the respective x and y axes are
'time (hr)'
and'area (sq. µm)'
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot data points in a semilog-y plot with axis labeles
_ = ____(____, ____, marker='.', linestyle='none')
# Generate x-values for the bootstrap lines: t_bs
t_bs = ____([____, ____])
# Plot the first 100 bootstrap lines
for i in range(____):
y = ____(____[i] * ____ + ____[i])
_ = ____(____, ____, linewidth=____, alpha=____, color=____)
# Label axes and show plot
_ = plt.xlabel('____')
_ = plt.ylabel('____')
____