Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Customize Your Scatter Plot | Scatter Plots
Visualization in Python with matplotlib

book
Customize Your Scatter Plot

Uppgift

Swipe to start coding

Set customizing parameters within the .scatter() function so that:

  • the points will be orange ('orange');
  • points size will be 1.5.

Lösning

# 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'],
c = 'orange', s = 1.5)

# Display the plot
plt.show()

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 6
# 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()
toggle bottom row
some-alt