Plot Scatter Graph with Python with Label and Title
import numpy as np
import matplotlib.pyplot as plt
gdp =[84580,76398,68402,65521,64684,61373]
life_exp =[80,82,77,83,75,82]
population =[300000,500000,100000,200000,5000000,600000]
Age vs GDP Correlate to Pouplation Size Represent by the Circle Area As the Population Figure is too Large , assign it a power of 0.5 too scale down the numbers
pop = np.array(population)
pop = np.array(pop)**0.5
plt.scatter(gdp, life_exp, s =pop)
<matplotlib.collections.PathCollection at 0x1818e2d6280>
xlab = 'GDP per Capita [in USD]'
ylab = 'Life Expectancy [in years]'
title = 'World Development'
Assign a cell a title x, y Label Log the x axis Scale to make it smaller Create 3 x series break point with xticks ( 1K , 10K, 100K)
plt.xlabel(xlab)
plt.ylabel(ylab)
plt.title(title)
plt.scatter(gdp, life_exp, s= pop)
plt.xscale('log')
plt.xticks([1000,10000,100000], ['1k','10k','100k'])
([<matplotlib.axis.XTick at 0x181904a26d0>, <matplotlib.axis.XTick at 0x181904a26a0>, <matplotlib.axis.XTick at 0x1819030f1f0>], [Text(1000, 0, '1k'), Text(10000, 0, '10k'), Text(100000, 0, '100k')])