Question: MATPLOTLIB This problem will test your ability to use the Python module matplotlib. For this problem, review the part of Section 7 . 1 1

MATPLOTLIB
This problem will test your ability to use the Python module matplotlib. For this problem, review the part of Section 7.11 labeled Plotting a Bar Graph. Review Programs 7-25 through 7-27 for examples of using matplotlib to create a bar graph. The example code provided with the lecture videos will be very useful as well.
Create a file named Lab06P4.py. Write a program that helps a user generate a line graph graphic:
a) As discussed in the book, you will need to use the Python utility pip to install matplotlib. Follow the instructions in the book for details.
b) After your program comment header, add the appropriate line for importing the module matplotlib that makes it convenient to work with the pyplot portion of the module:
import matplotlib.pyplot as plt
c) Your program should ask the user to enter a title for a bar graph.
d) The program should ask the user for labels for the x-axis and y-axis.
e) The program should ask the user for the number of data points.
f) Then your program should ask the user for the data point labels and values using a for loop. The labels will be used to label the bar locations on the x-axis. The values will be used to plot the bar heights to the y-axis.
g) After collecting the user's input into a list of labels and a list of values, use the appropriate pyplot functions to do the following:
a. Create the bar graph.
b. Add a title for the chart.
c. Add labels for the x-axis and y-axis.
d. Display the bar graph.
h) The program terminates after the user closes the window displaying the bar graph.
Sample output:
Enter the bar graph title: Daily Temps
Enter the label for the x-axis: Day of Week
Enter the label for the y-axis: Temperature
Enter the number of data points: 7
Enter the name for tick 1: Mon
Enter the value for tick 1: 66
Enter the name for tick 2: Tue
Enter the value for tick 2: 72.3
Enter the name for tick 3: Wed
Enter the value for tick 3: 76
Enter the name for tick 4: Thu
Enter the value for tick 4: 74.8
Enter the name for tick 5: Fri
Enter the value for tick 5: 82
Enter the name for tick 6: Sat
Enter the value for tick 6: 79.6
Enter the name for tick 7: Sun
Enter the value for tick 7: 75.1
Run this program. Enter any test data you would like. When your program displays the bar graph, use the save button to save the graph to a file named Lab06P4-output.png.
 MATPLOTLIB This problem will test your ability to use the Python

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!