import matplotlib.pyplot as plt
from cycler import cycler

from plot_helpers import CO, bold_ticks


def errors():
    # error plot for exercises

    plt.close("all")
    # get(gcf)
    fig, ax = plt.subplots(figsize=(8.8, 3.3))
    fig.subplots_adjust(left=0.10, right=0.98, bottom=0.22, top=0.98)
    ax.set_prop_cycle(cycler(color=CO))

    # ax.loglog([10, 1000], [1, 10**2], "--r", linewidth=2)
    # ax.loglog([10, 1000], [1, 1], "-b", linewidth=1.6)
    ax.loglog([10, 1000], [1, 1e-1], "--r", linewidth=1.8)
    ax.loglog([10, 1000], [1, 1e-2], "b", linewidth=1.8)
    ax.loglog([10, 1000], [1, 1e-4], "r", linewidth=1.6)
    ax.loglog([10, 1000], [1, 1e-8], "--b", linewidth=2)
    ax.set_xlim(10, 1000)
    ax.set_ylim(1e-8, 2)
    ax.set_yticks([1e-8, 1e-6, 1e-4, 1e-2, 1, 1e2])
    ax.set_xlabel("Number of Time Points")
    ax.set_ylabel("Iterative Error")
    ax.grid(True)
    bold_ticks(ax, 14)
    plt.show()

    # plt.savefig('/Users/mark/Desktop/p5.eps')


if __name__ == "__main__":
    errors()
