ComeçarComece de graça

What predicts animal longevity?

Let's pull this all together & port some MATLAB code over to Python.

A colleague sent you their MATLAB analysis of data from "AnAge: The Animal Ageing and Longevity Database." This database contains longevity data for over 4000 vertebrate animals, along with other data related to longevity.

You've loaded up the data in Python, and now you want to understand the relationship between the maximum longevity (stored in the numpy array max_longevity) of animals and the number of litters they produce each year (in litters_per_year). You've already imported pyplot and assigned it to the variable plt.

You have their MATLAB code plotting this relationship, but you need to port it over to Python.

Este exercício faz parte do curso

Python for MATLAB Users

Ver curso

Instruções do exercício

  • Convert comments to Python syntax.
  • Replace MATLAB plotting functions with their corresponding pyplot functions.
  • Show your plot.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

% Initialize the figure
figure

% Make the scatter plot
scatter(litters_per_year, max_longevity)

% Add axis labels
xlabel('Litters/Clutches per year')
ylabel('Maximum longevity (yrs)')

____.____()
Editar e executar o código