import matplotlib.pyplot as plt
import numpy as np
x = [1, 2, 3, 4, 5]
y = [2, 4, 3, 8, 5]
plt.rcParams.update({
    "font.family": "DejaVu Sans",
    "font.size": 11,
    "axes.titlesize": 19,
    "axes.titleweight": "bold",
    "axes.labelsize": 12,
    "xtick.labelsize": 10,
    "ytick.labelsize": 10,
    "axes.spines.top": False,
    "axes.spines.right": False,
    "axes.edgecolor": "#C9D2DC",
    "axes.linewidth": 0.9,
    "xtick.color": "#526174",
    "ytick.color": "#526174",
    "axes.labelcolor": "#344563",
    "text.color": "#172B4D",
    "savefig.dpi": 300,
    "savefig.bbox": "tight",
})
fig, ax = plt.subplots(
    figsize=(7, 5.4),
    facecolor="#F7F9FC"
)
ax.set_facecolor("#F7F9FC")
ax.plot(
    x, y,
    color="#2864DC",
    linewidth=3,
    marker="o",
    markersize=9,
    markerfacecolor="white",
    markeredgecolor="#2864DC",
    markeredgewidth=2.5,
    solid_capstyle="round",
    zorder=3,
)
imax = int(np.argmax(y))
ax.scatter(
    x[imax], y[imax],
    s=150,
    color="#F08A4B",
    edgecolor="white",
    linewidth=1.8,
    zorder=5,
)
ax.annotate(
    f"Maximum: {y[imax]}",
    xy=(x[imax], y[imax]),
    xytext=(14, -5),
    textcoords="offset points",
    fontsize=10,
    fontweight="bold",
    color="#B85B25",
    va="center",
)
fig.suptitle(
    "Change in Values Across Measurements",
    x=0.105,
    y=0.97,
    ha="left",
    fontsize=19,
    fontweight="bold",
    color="#172B4D",
)
ax.set_title(
    "Illustrative dataset: 5 observations",
    loc="left",
    fontsize=10,
    fontweight="normal",
    color="#718096",
    pad=18,
)
ax.set_xlabel("Measurement Number", labelpad=12)
ax.set_ylabel("Value", labelpad=12)
ax.set_xticks(x)
ax.set_ylim(0, 9.5)
ax.set_yticks(np.arange(0, 10, 2))
ax.margins(x=0.08)
ax.grid(
    axis="y",
    color="#DCE3EC",
    linewidth=0.9,
)
ax.grid(axis="x", visible=False)
ax.set_axisbelow(True)
fig.text(
    0.105,
    0.025,
    "Source: illustrative data",
    fontsize=8.5,
    color="#718096",
)
fig.subplots_adjust(
    left=0.105,
    right=0.96,
    top=0.78,
    bottom=0.17,
)
fig.savefig(
    "../imgs/publication_plot.png",
    dpi=300,
    bbox_inches="tight",
    facecolor=fig.get_facecolor(),
)
plt.show()
