PY-90
Make Comparable Evidence Figures
Task
Write make_comparable_figure(series, plot_form, x_label, y_label, comparison). series is a non-empty list of records with exactly three
keys: label, x, and y. Labels must be unique, non-empty strings. Convert
all numerical values to finite NumPy float64 arrays without changing the
inputs.
plot_form is one of "line", "scatter", or "histogram":
- For a line or scatter figure, each
xandyvalue is one-dimensional, non-empty, and equally long. Draw every series on the same axes in the supplied order. - For a histogram,
yis one-dimensional and non-empty.xmust beNone. Draw every series with the same explicit bin edges fromcomparison["bins"].
comparison may contain "x_limits" and "y_limits". Each supplied limit is
a pair of finite numbers in increasing order. Apply it exactly. Histograms
require "bins": a one-dimensional finite array with at least two strictly
increasing edges. Other plot forms must not receive "bins".
Use matplotlib.pyplot.subplots() and the explicit axes object. Set both axis
labels, add a legend, and return a dictionary with exactly these keys:
figure, axes, audit
audit must be a new dictionary containing plot_form, series_order,
x_label, y_label, x_limits, y_limits, and bins. Store applied limits
as tuples, or None when absent. Store histogram bins as a tuple, or None
for the other forms. Do not call show() or choose limits from one series
independently of another.
Example
The axes contains two labelled lines in before, after order. Both use the
same x- and y-limits, and the audit records those choices.
Your implementation
You may import NumPy as np and Matplotlib as plt. Do not print, show the
figure, or ask for input.