#!/usr/bin/env python3

import pathlib
import numpy as np
import matplotlib.pyplot as plt

methods = [
    ['Brev Utrikes', [
        [0.050,  44],
        [0.100,  66],
        [0.250,  85],
        [0.500, 110],
        [1.000, 170],
        [2.000, 210],
    ]],
    ['Rek 2000', [
        [0.050, 144],
        [0.100, 166],
        [0.250, 185],
        [0.500, 210],
        [1.000, 270],
        [2.000, 310],
    ]],
    ['Rek 10000', [
        [0.050, 184],
        [0.100, 206],
        [0.250, 225],
        [0.500, 250],
        [1.000, 310],
        [2.000, 350],
    ]],
    ['Postpaket Utrikes', [
        [1.000, 371],
        [2.000, 475],
        [3.000, 582],
        [4.000, 687],
        [5.000, 791],
        [6.000, 896],
        [7.000, 1002],
    ]],
]

name = pathlib.Path(__file__).stem
marker = '.'
for label, xy in methods:
    xy = np.array(xy)
    color = plt.plot(*xy.T, label=label, marker=marker)[0].get_color()
    if xy[-1][1] < 1000:
        exy = [xy[-1]]
        for i in range(1, 3):
            exy = np.append(exy, xy + i*xy[-1], 0)
        plt.plot(*exy.T, color=color, marker=marker, linestyle='dashed')
plt.xlim(left=0)
plt.ylim(bottom=0)
plt.xlabel('kg')
plt.ylabel('SEK')
plt.legend()
plt.savefig(f'{name}.png')
plt.show()