How about a 3D scatter chart

What if you have three variables : Life Expectancy, GDP and Population and want to see how they behave with each other.


So the blue blobs are how large the population is in some countries witch a certain overlap between life-expectancy and GDP.  The bigger the blob – the bigger the life expectancy.  How we achieve this is by introducing a numpy array of the third variable into the scatter chart.

Here the population (pop) is the 3rd variable:

# Import numpy as np
import numpy as np

# Store pop as a numpy array: np_pop
np_pop = np.array(pop)

# Update: set s argument to np_pop
plt.scatter(gdp_cap, life_exp, s = np_pop)

# Previous customizations
plt.xlabel(‘GDP per Capita [in USD]’)
plt.ylabel(‘Life Expectancy [in years]’)
plt.title(‘World Development in 2007’)
plt.xticks([1000, 10000, 100000],[‘1k’, ’10k’, ‘100k’])

# Display the plot



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: