def create_weather_line_graph(uid,line_types,line_arrays,date_array, fieldid): import matplotlib.pyplot as plt line_loc = 0 fig = plt.gcf() plt.rcParams.update({'font.size':20}) fig.set_size_inches(26,13) for line_array in line_arrays: index_array = line_array line_type = line_types[line_loc] print(line_type) day_array = date_array xtick_dates = [] new_index_array = [] len_day_array = len(day_array) new_day_array = [] w = 1 key_count = 0 for key in date_array: d_date = str(key) y = d_date[0:4] m = d_date[4:6] d = d_date[6:] if int(m)==1: M = 'Jan' elif int(m)==2: M = 'Feb' elif int(m) ==3: M = 'Mar' elif int(m) == 4: M = 'Apr' elif int(m) ==5: M = 'May' elif int(m) == 6: M = 'Jun' elif int(m) ==7: M = 'Jul' elif int(m) ==8: M = 'Aug' elif int(m)==9: M = 'Sep' elif int(m) ==10: M = 'Oct' elif int(m) ==11: M ='Nov' else: M = 'Dec' if len_day_array<7: n_date = d+'-'+M xtick_dates.append(n_date) if str(index_array[key_count]).find('not')>=0: new_index_array.append(0) else: new_index_array.append(index_array[key_count]) new_day_array.append(key) if len_day_array >6: if (len_day_array-key_count)<7: n_date = d+'-'+M xtick_dates.append(n_date) if str(index_array[key_count]).find('not')>=0: new_index_array.append(0) else: new_index_array.append(index_array[key_count]) new_day_array.append(key) key_count = key_count+1 #index_array = index_array[::-1] #day_array = day_array[::-1] #xtick_dates = xtick_dates[::-1] xlab = 'Days' if line_type.find('cloud_cover')>=0: title = 'Cloud Cover (in%) with time' ylab = 'Cloud Cover (%)' elif line_type.find('humidity')>=0: title = 'Humidity (in%) with time' ylab = 'Humidity (%)' elif line_type.find('pressure')>=0: title = 'Pressure (in hPa) with time' ylab = 'Pressue in (hPa)' elif line_type.find('wind_speed')>=0: title = 'Wind Speed (in m/s) with time' ylab = 'Wind Speed in m/s' elif line_type.find('wind_deg')>=0: title = 'Wind Direction (in degrees) with time' ylab = 'Wind Direction in degrees' elif line_type.find('min_temp')>=0: title = 'Min. and Max. Temperature vs Date' ylab = 'Temperature (°C)' elif line_type.find('max_temp')>=0: title = 'Min. and Max. Temperature vs Date' ylab = 'Temperature (°C)' #plt.legend(['Min Temp','Max Temp']) else: title = ' ' ylab = '' line_loc = line_loc+1 if line_loc>2: #line_loc=line_loc-1 plt.subplot(2,3,(line_loc-1)) plt.plot(new_day_array,new_index_array) elif line_loc==1: plt.subplot(2,3,1) plt.plot(new_day_array,new_index_array) else: print('came here') plt.plot(new_day_array,new_index_array) print(line_loc) #axs[line_loc].plot(new_day_array,new_index_array) #plt.xlabel(xlab) plt.ylabel(ylab) plt.title(title) plt.xticks(new_day_array,xtick_dates) plt.grid(b=True,which='major',color='#666666',linestyle='-') #axs[line_loc].set(xlabel=xlab,ylabel=ylab,title=title,xticks= #plt.subplots_adjust(left=0.0,right=0.5,bottom=0.0,top=0.5) plt.show() file_name = uid+'/' + fieldid +'/weather_linegraph.png' plt.savefig(file_name) plt.close()