1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| def plot_daily_new_cases(newdf): ''' plot australia daily new coronavirus cases ''' plotdf = newdf.reset_index().melt(id_vars = 'index') sns.set(style='darkgrid', palette='deep', font='sans-serif', font_scale=2, color_codes=True, rc={"lines.linewidth": 6,'lines.markersize': 14}) fig,ax = plt.subplots(figsize=(24,10)) ax = sns.lineplot(x='index',y='value',hue='variable',data=plotdf, marker='o', dashes=True) ax.set(title="Australia Daily New Covid-19 Cases") ax.xaxis.set_major_locator(ticker.MultipleLocator(1)) ax.set_xlabel("Date",fontsize=30) ax.set_ylabel("Number of Cases",fontsize=40) ax.xaxis.set_tick_params(labelsize = 16,rotation=15)
item = plotdf.groupby('variable') palette = sns.color_palette('deep').as_hex()
for i in range(newdf.shape[1]): curdf = newdf.iloc[:,i].to_frame().reset_index().values for x,y in curdf: ax.text(x,y,f'{y:d}',color=palette[i])
plot_daily_new_cases(newdf)
|