Plot the bar chart of a dataset

Assignment Help Python Programming
Reference no: EM132158070

Project

Project Objectives
This project requires you to use the graphics module in Python called Turtle to plot a bar chart. You have to compose the chart from basic graphic elements like points, lines and texts using functions in Turtle.

You can jump to the section titled "Step 4 Plot the bar chart of a dataset" for the project requirements.

The project
What you need to produce and submit at the end of this project is a program that plots a bar chart for a given dataset. You are free to design the program in the way you want, so long as it is neat and clear. We will describe the problem later. Here, we first give you a progressive guide on how to do drawings.

You have four weeks for the project. The guide below breaks your progress down to four steps, and you can take one step per week, more or less. If you follow them well, you should be able to produce the desired results at the end. However, we expect that some of you will be able to do it ahead of time.

Step 1 - learn to use Turtle functions
Learn how to use Turtle functions to do some simple drawings. Try these:
- Draw a line, using the direction functions like forward(), backward(), right(), left() etc., with appropriate parameters, of course.
- Draw a line, by specifying coordinates to draw to, using the goto() function, with appropriate control of penup() and pendown().
- Vary the widths of the lines you draw by using pensize().
- Draw multiple lines in different directions, connected and not connected. Try drawing lines to write the word "turtle" or any word you choose.
- Draw a few closed shapes: triangles, rectangles and shapes of your own design, of different sizes, and fill them with colours, especially rectangles, of course, since the bars are rectangular.
- Write some text in the picture.
- Try different colours, for the lines, the textsand the filling of the shapes.

You will see that the default setting of Turtle is to display a triangular arrow head, which represents the turtle, pointing to a specific direction that you can change.Also the display is done in slow animation. Learn to change these defaults, as you may want a different behavior when you plot your graph.

Please refer to the "Turtle star" program given at the top of Section 24.1 for a short example of what can be done.

Step 2 - learn to draw proper diagrams
A proper diagram is one that has controlled appearances, such as sizes, shapes and colours. Do these exercises:
- Create a display window of specific size using the setup() function
- In the window, plot the axes of a graph which should be perpendicular to each other. You should be able to control the extent of the axes in both directions.
- Label the axes with appropriate text like "distance", "time", etc. depending on the need
- Place tick marks sensibly at regular intervals along the axes
- Label the tick marks with appropriate values
- Learn to place rectangular bars of given sizes where you want them.

Some of the exercises will require you to design simple algorithms to achieve the outcome, such as placing the tick marks at appropriate locations and label them with appropriate values. You decide what "appropriate" is.

Step 3 -Display things in real coordinates
We have not yet mentioned the coordinate system in which you do your drawing. It is likely that you have simply done the drawing so far using the native coordinate system of turtle, which is the pixel coordinates of the screen. That's because you have not specified a coordinate system.

In real life, things come in different shapes and sizes, and they all have to be drawn on a screen that has a fixed maximum size, based on the number of pixels in the x and y directions. That is the "screen coordinates" or "device coordinates". Real things do not conform to the screen coordinates, but have sizes and positions of their own. A thing 10m long can be displayed on a screen, another thing 0.1m long can be displayed on the same screen, but yet looks equally big. Clearly they are displayed at different scales. Hence you need to learn to display things at the appropriate scale so that they appear comfortable to the eyes when displayed.

You should create algorithms/functions to do the following:
- Create a display window of some specific size, as you did last week.
- Decide on the dimension of the object you wish to display, and create a function that would scale it to allow it to be displayed appropriately on the screen
- Generate an object of your choice (such as a rectangle) with its own dimensions, and display it appropriately on the screen

Step 4 - Plot the bar chart of a dataset

By now you should have gathered the tools you need to draw real bar charts. You are required to write a program to display the dataset given in the text file bulb.txt. The file contains one column of numbers, which are the number of hours a bulb burns continuously before expiring. You are required to plot a bar chart showing the distribution of these hours, by dividing the range of the measurements into 10 segments, from the low to the high, count the number of measurements in each segment and plot the number against the segments as a bar chart.

Computational thinking:
You need to separate the organization of the data from the plotting of the bar chart. The chart is only a display of the data in the way you need to visualize it. So you first need to organize the data, then display it in a bar chart. The description above suggests to you the steps.

1. Find the range of the hours.

2. Divide this range into ten segments, each segment is for 1/10 of the range.

3. Count the number of measurements in each range.

4. Plot the bar chart for the ten segments. You need to decide what the chart should contain.

5. The plotting of the bar chart itself is a major task, and you should have gathered the computational process for it from the earlier exercises.

Attachment:- pyt.zip

Reference no: EM132158070

Questions Cloud

Composition of various types of shells : Considering the function a composition of various types of shells, explain why turtles, clams and crabs all have shells but are in different phyla?
Even though both earthworms and nematodes : Even though both earthworms and nematodes are called "worms" they are classified in different phyla. Why is this so?
Emergent property that appears at the level of the cell : Discuss this statement: life is an emergent property that appears at the level of the cell.
Dna sequence that is followed by another : Framework Mutation Question: If there is an insertion of a codon (TAC) at the beginning of a DNA sequence that is followed by another TAC codon
Plot the bar chart of a dataset : MA1008 Introduction to Computation Thinking - Compose the chart from basic graphic elements like points, lines and texts using functions in Turtle
Negative frequency from the general population : If the student enrollment at JCCC is 19,000 and we use the Rh negative frequency from the general population, how many students should have each of the three
Guinea pigs of opposite sex : If you had two guinea pigs of opposite sex, both homozygous, one black and one brown, but you did not know which was the dominant characteristic
How does atrazine act to kill plants : Predict how this would affect both parts of photosynthesis. Be as detailed as possible, and include in your answer both of the main steps in photosynthesis.
Evening and happen to stumble into the path of a skunk : HELP! Imagine that you are out for a walk on a late summer evening and happen to stumble into the path of a skunk

Reviews

len2158070

11/2/2018 5:03:20 AM

This is a small independent take-home project, i.e. a project that you need to execute on your own, at your own time. It is expected that you would typically spend 3-5 hours on the project per week over the four weeks. You can use all the resources available, except getting someone else to do it for you.You may refer to documents that discuss algorithms for constructing charts, but you must construct the chart using Turtle functions, and not call a chart plotting routine that is already available elsewhere.

len2158070

11/2/2018 5:02:55 AM

Submit your program through your Assignment link in the course site. Do not submit it through any other means. It is your responsibility to ensure that your program and image are submitted properly. Please name your file with your full name. The first line of your program should be a comment line bearing your full name and your matric number. Marks will be awarded as follows: Design of the algorithm (the logic is correct and efficient) – 25% Clear and sensible Python code (the code is easy to follow, well organized and modularised) – 25% Correctness of the solution – 30% Quality of the output – 20%

len2158070

11/2/2018 5:02:48 AM

Please refer to attached document for instructions. Program according to the stipulated requirements in the attached document You will need to submit your program by the end of Week 13, i.e. by Friday, 17, 5 p.m.You are also required to capture the screen output of your bar chart and submit it either as an image file or a Word or PowerPoint file that contains the bar chart image.

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd