from matplotlib import pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches

plt.figure(figsize=(12, 10))

# Line
plt.plot([1.0, 2.0], [1.0, 2.0], marker='o', markersize=10, color='black', linestyle='dashed')
plt.annotate("x", (1.05, 0.9), fontsize='xx-large')
plt.annotate("y", (2.05, 1.9), fontsize='xx-large')

# Convex combination
plt.plot([1.5], [1.5], marker='o', markersize=10, color='blue')
plt.annotate("comb(x, y)", (1.2, 1.55), fontsize='xx-large')

# Third point
plt.plot([1.5], [1.1], marker='o', markersize=10, color='blue')
plt.annotate('p', (1.55, 1.0), fontsize='xx-large')

# Suggested convex surface
vertices = [
    (1.0, 1.0), # Start point
    (1.2, 1.0), # Beizer control point
    (1.5, 1.1), # Beizer midpoint
    (1.8, 1.2), # Beizer control point
    (2.0, 2.0)  # End point
]

codes = [
    Path.MOVETO,
    Path.CURVE3,
    Path.CURVE3,
    Path.CURVE3,
    Path.LINETO
]

path = Path(vertices, codes)
patch = patches.PathPatch(path, facecolor='none', lw=2)
plt.gca().add_patch(patch)

plt.annotate("Suggested\nconvex surface", (1.85, 1.3), fontsize='xx-large')


plt.xlim(0.5, 2.5)
plt.ylim(0.5, 2.5)
plt.gca().get_xaxis().set_ticks([])
plt.gca().get_yaxis().set_ticks([])
plt.xlabel('Genotype', fontsize=20)
plt.ylabel('Fitness', fontsize=20)
plt.title("Convexity Sample Illustration", fontsize=20);