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?
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()