import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport altair as altfrom sklearn.datasets import load_irisimport plotly.express as pximport plotly.io as piopio.renderers.default='plotly_mimetype+notebook_connected'import warningswarnings.filterwarnings('ignore')
wb19 = wbpivot[wbpivot['Year'].isin(['2019'])]wb19["Life expectancy at birth, total (years)"] = pd.to_numeric(wb19["Life expectancy at birth, total (years)"])hospital_sort = wb19.sort_values("Life expectancy at birth, total (years)")x=hospital_sort["Country Name"]y=hospital_sort["Life expectancy at birth, total (years)"]plt.plot(x, y, 'o')plt.ylim(y.min()*0.9, y.max()*1.1)plt.ylabel("Life Expectancy at Birth (Years)") plt.xlabel("Country")plt.title("Life Expectancy (2019)")for xi, yi inzip(x, y): plt.text(xi, yi+0.6, str(round(yi, 2)), ha='center')plt.show()
The first graph shows the hospital beds per capita over a 5 year period. 3 countries remained stagnant while China saw increases over the time period and France declined. The annotations on the graph specify how much change happened in China and France over the 5 year period. I decided to use +/- signs as well as color coding to indicate the positive or negative value of change. I also placed the values in between the datapoints to simply show which two years is being compared.
The next graph is a simple, sorted dotplot of life expectancy. I added text labels to each datapoint to show the exact values for each country. This is not a major change but it does help with comparing countries that are close together on the graph, allowing viewers to see the decimal values.
The styled table has a few key components that make it a proper visualization. First, the data values are rounded and have an appended percentage sign to help you read and understand what the datatype is. Second, everything is aligned to make the table look more organized and increase readability further. Lastly, I added a title to show you what the table is representing. These three small details are what makes the table adequate compared to the raw, unedited version.