Write a function graph_line_colour (vals, colour) where vals (type list) and colour (type string) are two input paramete

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a function graph_line_colour (vals, colour) where vals (type list) and colour (type string) are two input paramete

Post by answerhappygod »

Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 1
Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 1 (31.95 KiB) Viewed 15 times
Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 2
Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 2 (14.63 KiB) Viewed 15 times
Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 3
Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 3 (34.61 KiB) Viewed 15 times
Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 4
Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 4 (34.27 KiB) Viewed 15 times
Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 5
Write A Function Graph Line Colour Vals Colour Where Vals Type List And Colour Type String Are Two Input Paramete 5 (25.07 KiB) Viewed 15 times
Write a function graph_line_colour (vals, colour) where vals (type list) and colour (type string) are two input parameters. The function graph_line_colour (vals, colour) should return a pyplot object plt (e.g., import matplotlib.pyplot as plt) where colour specifies the line colour (e.g., red, blue, etc.) of the graph if it is saved as a figure. Note: the function save_pit (plt1, "output.png") shown in the test cases is creating "output.png" from a pyplot object plt1. For the test cases 1 and 2, your graphs should look something like these (test case 1 on left/top, test case 2 on right/bottom): 8 7 5 3 21 1 O -3 s.

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'
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply