Python代写:CPSC217 Climograph

Python的画图类型作业,用给的SimpleGraphics.py库来实现,这个库基于tkinter,但是相比前者要精简许多。

Description

A climograph is a visual representation of the climate for a location. it shows temperature data using a red line, and precipitation data using blue bars. One temperature point and one precipitation bar are plotted for each month of the year. An example climograph, using climate data from Victoria, BC, is shown below.

Your program will draw a climograph using data entered by the user. It will begin by drawing the graph components such as the axes, month names and labels. Then it will read 12 precipitation values, one for each month from January to December, and draw the appropriate bars. Your program will conclude by reading 12 temperature values for January through to December and plotting the temperature data.

Each temperature value will be plotted asa red dot. A red line will connect the dot for each month to the dot for the previous month (except for January).

Additional Requirements

  • You must make appropriate use of loops. While it is acceptable to use a long series of statements to place the month names on the graph, the numeric labels for temperatures and precipitation must be displayed using a loop. You must also use loops to read input from the user and draw the precipitation bars / temperature lines. An assignment that uses 24 distinct input statements to read the precipitation and temperature data will receive a grade of D or less, even if everything works perfectly.

  • Your program must leave appropriate gaps between the bars.

  • Your graph must include small tick marks next to the temperature and rainfall numeric labels, as shown in the sample output.

  • Your program should use a temperature scale that ranges from -20 to +20 degrees Celsius, and a precipitation scale that ranges from 0 to 200 millimeters. If you receive a value outside of these ranges you should still plot it - it will just appear above or below the axes.

Hints

  • You will probably find the dots for the temperature data easier to plot than the bars for the precipitation data. As such, you might want to tackle the dots for temperature data first, even though it is entered after the precipitation data.

  • You will probably find the precipitation data easier to plot than the lines for the temperature data. As such, you might want to tackle the precipitation data before trying to draw the lines for the temperature data.

  • The temperature data spacing will work out nicely if you represent 1 degree Celsius by 10 pixels.

  • The precipitation data spacing will work out nicely if you represent 1 millimeter of precipitation by 2 pixels.

  • The spacing will work out nicely if you allocate 50 pixels to each month of the year.

  • Every time you run your program you will need to enter 24 data values. You can automate this by using a feature known as l/O redirection, which will allow your program to read the values from a file instead of from the keyboard. For example, to use the values from the file named Calgary.txt instead of reading values from the keyboard, enter the command:

python A3n2.py < Calgary.txt

The details of how I/O redirection works aren’t important within the scope of this course. but your ability to use it by following the pattern above will save you a significant amount of typing. Several sample data sets saved in the correct format are available on the course website. Feel free to get as much help as you need on I/O redirection from the Us or instructor.

Grading

This assignment will be graded on a combination of functionality and style. A base grade will be determined from the general level of functionality of the program (Does it draw the axes and labels successfully? Does it plot the precipitation data correctly? Does it plot the temperature data correctly?). The base grade will be recorded as a mark out of 12.

Style will be graded on a subtractive scale from 0 to -3. For example, an assignment which receives a base grade of 12 (A), but has several stylistic problems resulting in a -2 adjustment will receive an overall grade of 10 (3+). Fractional marks will be rounded to the closest integer.

Individual Work

All assignments in this course are to be completed individually. Students are advised to read the guidelines for avoiding plagiarism located on the course website. Students are also advised that electronic tools may be used to detect plagiarism.

late Penalty

Late assignments will not be accepted.

Submission Instructions

Your program must be submitted both on paper and electronically. Paper submissions, consisting of a printed copy of your .py file, should be deposited in the appropriate assignment drop box on the second floor of the math sciences building. Your electronic submission should be submitted to the Assignment 2 drop box in DZL.