Create a Simple Scatter Plot
Tarefa
Swipe to start coding
The 'gapminder' data is loaded in the dataframe data
. Your tasks are:
- Initialize scatter plot with the
'gdp per capita'
column values on the x-axis, and'life exp'
column values on the y-axis. - Display the plot.
Solução
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Import the libraries
import pandas as pd
import matplotlib.pyplot as plt
# Load the data
data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/ed80401e-2684-4bc4-a077-99d13a386ac7/gapminder2017.csv', index_col = 0)
# Create Figure and Axes objects
fig, ax = plt.subplots()
# Initialize the scatter plot
ax.scatter(data['gdp per capita'], data['life exp'])
# Display the plot
plt.show()
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 2
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Import the libraries
import pandas as pd
import matplotlib.pyplot as plt
# Load the data
data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/ed80401e-2684-4bc4-a077-99d13a386ac7/gapminder2017.csv', index_col = 0)
# Create Figure and Axes objects
fig, ax = plt.subplots()
# Initialize the scatter plot
___.___(data['___'], data['___'])
# Display the plot
___.___()
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo