Average new car fuel consumption

import matplotlib.pyplot as plt years = list(range(2000, 2017)) consumption_by_year = { 'petrol car': { 'litres per 100km': [8.0, 7.9, 7.8, 7.7, 7.6, 7.5, 7.4, 7.2, 7.0, 6.5, 6.3, 6.1, 5.8, 5.6, 5.5, 5.4, 5.4], 'miles per gallon': [35.3, 35.8, 36.2, 36.8, 37.0, 37.5, 38.3, 39.0, 40.5, 43.4, 44.6, 46.3, 48.3, 50.1, 51.1, 52.0, 52.2] }, 'diesel car': { 'litres per 100km': [6.3, 6.2, 6.1, 6.2, 6.2, 6.2, 6.3, 6.2, 5.9, 5.7, 5.5, 5.2, 5.0, 4.9, 4.7, 4.6, 4.5], 'miles per gallon': [44.6, 45.5, 46.0, 45.5, 45.7, 45.4, 45.1, 45.7, 47.7, 49.4, 51.8, 54.4, 56.2, 58.0, 59.9, 61.6, 62.2] } } colors = {'petrol car': 'black', 'diesel car': 'orange'} fig, ax = plt.subplots(len(consumption_by_year), sharex=True) for car_fuel_type, categories in consumption_by_year.items(): for i, (measurement_unit, values) in enumerate(categories.items()): ax[i].set_title(measurement_unit.capitalize()) ax[i].plot(years, values, color=colors[car_fuel_type], label=car_fuel_type) ax[i].legend(loc='best', frameon=False) ax[i].set_xlim(2000,2016) print('%s %s: %.2f%%' % ( car_fuel_type.capitalize(), measurement_unit, (max(values) / min(values) - 1) * 100 )) plt.tight_layout() plt.show() """ Percentage improvement between 2000 and 2016 (slightly rearranged): Petrol car miles per gallon: 47.88% Diesel car miles per gallon: 39.46% Petrol car litres per 100km: 48.15% Diesel car litres per 100km: 40.00% We see that petrol cars have improved slightly more in both categories. Source: Department of Transport, table ENV0103 """ Consumption of new cars by fuel type