Write a function graph_line_colour (vals, colour) where vals (type list) and colour (type string) are two input paramete
Posted: Mon Jun 06, 2022 6:12 pm
8 7 6 5 4 3 2 1 لب 1 2 3 لیا 5
note: the colour will always be a valid colour. For example: Test Result plt1 graph_line_colour ([1, 3, 6, 5, 8, 71, 'red') Pass! save_plt(plt1, "output.png") plt2 ans ([1, 3, 6, 5, 8, 71, 'red') save_plt (plt2, "ans.png") val= main("output.png", "ans.png") if val <= 0.0001: print("Pass!") else: print("Your graph is different to the expected output, difference: {:.4f}".format(val)) plt1 = graph_line_colour ([1, 3, 6, 5, 8, 71, 'green') Pass! save_plt(plt1, "output.png") plt2 = ans ([1, 3, 6, 5, 8, 71, 'green') save_plt (plt2, "ans.png") val= main("output.png", "ans.png") if val < 0.0001: print("Pass!") else: print("Your graph is different to the expected output, difference: {:.4f)". format (val))
1 import matplotlib.pyplot as plt 2 import numpy as np 3 def graph_line_colour(data, color): """plots fig""" fig plt. figure() plt.plot(data, color) return fig Precheck Check Test Expec xplt1 = graph_line_colour ([1, 3, 6, 5, 8, 71, 'red') Pass! save_plt(plt1, "output.png") plt2 ans ([1, 3, 6, 5, 8, 71, 'red') save_plt(plt2, "ans.png") val= main("output.png", "ans.png") if val 0.0001: print("Pass!") else: print("Your graph is different to the expected output, difference: {:.4f)". format(val))
Expected Got Pass! ***Error*** X Traceback (most recent call last): File "_tester_.python3", line 58, in <module> save_plt (plt1, "output.png") File "_tester_.python3", line 20, in save_plt plt.close() AttributeError: 'Figure' object has no attribute 'close'