A chart that only shows lines makes the reader do the work. The good ones point: an arrow at the peak with its value, a dashed line at the target, a shaded band over the period that mattered, a legend that says which colour is which. These extras are cheap to add and are what turn a plot from "data" into "an argument". They are also objects, Annotation, Line2D and Polygon patches, with positions and text you can read back.
This question builds four such touches: an annotated maximum, a horizontal threshold with a label, a shaded span between two x values, and a legend placed outside the plot area so it never hides data.
Implement annotate_max(ax, x, y), add_threshold(ax, value, label), shade_region(ax, x0, x1, label) and legend_below(ax, title). The signatures and docstrings are already in the editor.
annotate_max(ax, x, y) finds the point with the largest y (the first one if tied) and adds an annotation whose text is f"max = {y_max:g}", which points at (x_max, y_max) with an arrow, with its text placed 20 points above that point (xytext=(0, 20), textcoords="offset points"). It returns the Annotation.add_threshold(ax, value, label) draws a horizontal line at y = value, colour "gray", linestyle "--", with that label, shows the legend, and returns the line.shade_region(ax, x0, x1, label) shades the vertical band between x0 and x1 with colour "orange" and alpha=0.2 and the given label, and returns the patch.legend_below(ax, title) shows the legend with that title, centred under the axes (loc="upper center", bbox_to_anchor=(0.5, -0.15)) in two columns, and returns the Legend.x and y are equal-length numeric sequences. Do not call plt.show().ax.annotate(text, xy=point, xytext=offset, textcoords="offset points", arrowprops=dict(arrowstyle="->")) creates an Annotation. Without arrowprops there is no arrow.
ax.axhline(y, ...) is a line across the whole width. ax.axvspan(x0, x1, ...) is a shaded vertical band.
ax.legend(...) returns the Legend object. bbox_to_anchor moves it relative to the axes.
No results yet
Run your code to check it against the examples, or submit to run every test.