From 2e731f31de188c98f2264380aeecae43bc73dc91 Mon Sep 17 00:00:00 2001 From: Waylon Walker Date: Sat, 1 Apr 2017 13:50:46 -0500 Subject: [PATCH] initial commit /n/n co2plot.py makes the plots. runnint Processing chunk 1 named None from line 3 Processing chunk 2 named None from line 10 Processing chunk 3 named None from line 17 Processing chunk 4 named None from line 28 Published co2plot.py to co2plot.html will create the report --- co2plot.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 co2plot.py diff --git a/co2plot.py b/co2plot.py new file mode 100644 index 0000000..69c4ca5 --- /dev/null +++ b/co2plot.py @@ -0,0 +1,32 @@ +#' #Testing out pweave on android with Termux + +import matplotlib +matplotlib.use('agg') +from tabulate import tabulate +from co2data import df + +#' ## raw data +#' *from data.world* +# This example will plot the co2 emissions trend for the top 5 countries in 2011 + + +print(tabulate(df.iloc[0:10, 0:5], headers=df.columns, tablefmt='simple')) + +#' ## Transform Data for plotting +#' +plot_df = (df + .set_index('CO2 emission total') + .sort_values('2011', ascending=False) + .head(5) + .T + .dropna(how='all') + ) + +print(tabulate(plot_df.iloc[0:10, 0:5], headers=plot_df.columns, tablefmt='simple')) + +#' Plot the data +title = 'Top 5 countries CO2 emissions trend\n(based on 2011 emissions data)' +ax = plot_df.plot(title=title) +ax.figure.savefig('tmp.png') + +