import matplotlib.pyplot as plt Country = ['USA','Japan','Germany','UK','France','Turkey','Mexico','Italy','Canada','Spain'] TotalCases = [1.26e+08,2.88e+06,1.18e+07,2.91e+07,2.76e+07,1.65e+07,9.82e+06,1.39e+07,4.42e+06,1.96e+07 ] plt.figure(figsize=(15,4)) plt.bar(Country, TotalCases) plt.xticks(rotation=0) plt.xlabel("Country") plt.ylabel("Total Cases from 2020-2021 (3sf)") plt.title("Total COVID-19 Cases of the 10 Wealthiest OECD Countries from 2020-2021 (3sf)") def addlabels(x,y): for i in range(len(x)): plt.text(i, y[i], y[i], ha = 'center') addlabels(Country, TotalCases) plt.savefig('cases.png', dpi=300, bbox_inches='tight') plt.show()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter