|
@ -9,7 +9,7 @@ class c_settings_extractor: |
|
|
def __init__(self, fname): |
|
|
def __init__(self, fname): |
|
|
with open(fname, "r") as rf: |
|
|
with open(fname, "r") as rf: |
|
|
settings = json.load(rf) |
|
|
settings = json.load(rf) |
|
|
kilometer_price_ccar = settings["ccar"]["litres_per_kilometer"] * settings["petrol_litre_price"] |
|
|
kilometer_price_ccar = settings["ccar"]["litres_per_kilometer"] * settings["juice_litre_price"] |
|
|
self.labels = [settings["ecar"]["label"], settings["ccar"]["label"]] |
|
|
self.labels = [settings["ecar"]["label"], settings["ccar"]["label"]] |
|
|
self.purchase = np.array([settings["ecar"]["price"], settings["ccar"]["price"]]) |
|
|
self.purchase = np.array([settings["ecar"]["price"], settings["ccar"]["price"]]) |
|
|
self.taxes = np.array([settings["ecar"]["taxes"], settings["ccar"]["taxes"]]) |
|
|
self.taxes = np.array([settings["ecar"]["taxes"], settings["ccar"]["taxes"]]) |
|
@ -138,22 +138,26 @@ def main(): |
|
|
current_y = current_y + maintenance |
|
|
current_y = current_y + maintenance |
|
|
y += 1 |
|
|
y += 1 |
|
|
labels = ["Purchase", "Taxes", "Insurance", "Driving", "Maintenance"] |
|
|
labels = ["Purchase", "Taxes", "Insurance", "Driving", "Maintenance"] |
|
|
|
|
|
lnspace_start = -0.2 |
|
|
|
|
|
lnspace_stop = 1.2 |
|
|
|
|
|
lnspace_n = 10 |
|
|
|
|
|
x_text = 0.2 |
|
|
if args.break_even: |
|
|
if args.break_even: |
|
|
months_a_year = 12.0 |
|
|
months_a_year = 12.0 |
|
|
be_money = (be_years + be_months/months_a_year) * comparator.calculate_costs_a_year() |
|
|
be_money = (be_years + be_months/months_a_year) * comparator.calculate_costs_a_year() |
|
|
be_money = be_money[1] + extractor.get_purchase() |
|
|
be_money = be_money[1] + extractor.get_purchase() |
|
|
ax.plot(np.linspace(-0.2, 1.2, 10), [be_money[1]]*10, "--", color = plt_colors[2], label = "Break even") |
|
|
ax.plot(np.linspace(lnspace_start, lnspace_stop, lnspace_n), [be_money[1]]*lnspace_n, "--", color = plt_colors[2], label = "Break even") |
|
|
ax.text(0.3, be_money[1] + 100, "Break even: {} years, {} months, {} kilometers".format(be_years, be_months, be_kilometers)) |
|
|
ax.text(x_text, be_money[1] + 100, "Break even: {} years, {} months, {} kilometers".format(be_years, be_months, be_kilometers)) |
|
|
labels = ["Break even"] + labels |
|
|
labels = ["Break even"] + labels |
|
|
if args.amortization: |
|
|
if args.amortization: |
|
|
months_a_year = 12.0 |
|
|
months_a_year = 12.0 |
|
|
am_money = (am_years + am_months/months_a_year) * comparator.calculate_costs_a_year() |
|
|
am_money = (am_years + am_months/months_a_year) * comparator.calculate_costs_a_year() |
|
|
am_money = am_money[1] + extractor.get_purchase() |
|
|
am_money = am_money[1] + extractor.get_purchase() |
|
|
ax.plot(np.linspace(-0.2, 1.2, 10), [am_money[1]]*10, "--", color = plt_colors[2], label = "Amortization") |
|
|
ax.plot(np.linspace(lnspace_start, lnspace_stop, lnspace_n), [am_money[1]]*lnspace_n, "--", color = plt_colors[2], label = "Amortization") |
|
|
ax.text(0.3, am_money[1] + 100, "Amortization: {} years, {} months, {} kilometers".format(am_years, am_months, am_kilometers)) |
|
|
ax.text(x_text, am_money[1] + 100, "Amortization: {} years, {} months, {} kilometers".format(am_years, am_months, am_kilometers)) |
|
|
labels = ["Amortization"] + labels |
|
|
labels = ["Amortization"] + labels |
|
|
ax.set_ylabel(extractor.get_currency()) |
|
|
ax.set_ylabel(extractor.get_currency()) |
|
|
ax.set_title("Comparision of economics electric vs. combustion car") |
|
|
ax.set_title("Comparision of economics: Electric vs. combustion car") |
|
|
ax.legend(labels) |
|
|
ax.legend(labels) |
|
|
ax.grid(axis = "y") |
|
|
ax.grid(axis = "y") |
|
|
plt.show() |
|
|
plt.show() |
|
|