Created
June 17, 2018 04:42
-
-
Save oliverangelil/ec5d7f404927b7b19b1fe93449ba733c to your computer and use it in GitHub Desktop.
Maize Yield for Siya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pandas as pd | |
import matplotlib as mpl | |
mpl.use('Agg') | |
import matplotlib.pyplot as plt | |
path_maize = '/home/siyabusa/terra/Forecast_ProcessedFiles/Outputs/Maize/' | |
files_maize = sorted([i for i in os.listdir(path_maize) if i.endswith('ec1.csv')]) | |
names = [] | |
maize_yield = pd.DataFrame() | |
maize_yield.index = pd.to_datetime(maize_yield.index) | |
for count, f in enumerate(files_maize): | |
file_contents = pd.read_csv(path_maize + f) | |
maize_yield = pd.concat([maize_yield, file_contents.ix[0, 1:]], axis=1) | |
names.append(f[6:-4] + '_COLFIR') | |
maize_yield.columns = names | |
ax = maize_yield.plot(figsize=(20, 10)) | |
ax.set_xlabel('Planting Date', fontsize=20) | |
ax.set_ylabel('Maize Yield [kg/ha]', fontsize=20) | |
ax.tick_params(axis='both', labelsize=16) | |
plt.legend(ncol=4, loc='lower center', bbox_to_anchor=(0.5, -0.5), fontsize=16) | |
plt.savefig('/home/siyabusa/siya.png', bbox_inches='tight', dpi=200) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment