Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Create a Simple Scatter Plot | Scatter Plots
Visualization in Python with matplotlib

book
Create a Simple Scatter Plot

Tarefa

Swipe to start coding

The 'gapminder' data is loaded in the dataframe data. Your tasks are:

  1. Initialize scatter plot with the 'gdp per capita' column values on the x-axis, and 'life exp' column values on the y-axis.
  2. Display the plot.

Solução

# 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?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 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
___.___()

Pergunte à IA

expand
ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

We use cookies to make your experience better!
some-alt