मराठी

Plot the following data using a line plot: Day Tickets sold 1 2000 2 2800 3 3000 4 2500 5 2300 6 2500 7 1000 Before displaying the plot display “Monday, Tuesday, Wednesday, Thursday, Friday,

Advertisements
Advertisements

प्रश्न

Plot the following data using a line plot:

Day 1 2 3 4 5 6 7
Tickets sold 2000 2800 3000 2500 2300 2500 1000
  • Before displaying the plot display “Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday” in place of Day 1, 2, 3, 4, 5, 6, 7
  • Change the color of the line to ‘Magenta’.
कोड लेखन
Advertisements

उत्तर

import matplotlib.pyplot as plt
day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 
       'Friday', 'Saturday', 'Sunday']
tickets = [2000, 2800, 3000, 2500, 2300, 2500, 1000]
plt.plot(day, tickets, color='magenta')
plt.title("Tickets Sold in a Week")
plt.xlabel("Days")
plt.ylabel("Number of Tickets Sold")
plt.show()

Output:

  • Days (Monday to Sunday) on the X-axis
  • Tickets sold on the Y-axis
  • Line colour set to magenta.
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 4: Plotting Data using Matplotlib - Exercise [पृष्ठ १३५]

APPEARS IN

एनसीईआरटी Informatics Practices [English] Class 12
पाठ 4 Plotting Data using Matplotlib
Exercise | Q 10. | पृष्ठ १३५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×