예제 #1
0
	def save_histogram(self):
		''' Saves a plot in ./figures containing a histogram of 
		the distribution of GDP per region for the year corresponding
		to self.year '''	
		for region in self.REGIONS:
			save_to = './figures/gdp_histogram_{}_{}'.format(self.year,region)
			year_gdp_histogram( self.data, self.year, region=region, save_path=save_to )
			print('Histogram for year {} and region {} saved to {}'.format(self.year,region,save_to))
예제 #2
0
				#Go to the top of thw while
				print('Invalid input, please try again')
				continue

			if year == 'finish':
				break

			try:
				year = int(year)
			except ValueError:
				# Year is not a string representation of an int
				print('\nInvalid input, please try again')
				continue

			try:
				year_gdp_histogram(DataExploration.income, year)
			except ValueError:
				print('Invalid year, please try again with an year between {} and {}'.format(year_min,year_max))
				continue


		years = range(2007,2013)
		for year in years:
			DataExploration(year).save_boxplots()
			DataExploration(year).save_histogram()



	except (defined_exceptions.FatalError), exception:
		print(exception.message)
		print('Error encountered: Program will exit now')