Create a Simple Scatter Plot
Tarea
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.
Solución
# 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()
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 3. Capítulo 2
# 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
___.___()