For this challenge we are going to use Python turtle to create some charts: Column charts, line charts and radar charts.
First we need a data set. We will use the following data that shows the market share of the four most popular browsers in 2015.
|IE / Edge||14%|
Using Python Turtle, create the following charts:
Looking at the following code can you explain the purpose of each Python Turtle instructions:
- myPen.write(“Hello World”, None, “center”, “16pt bold”)
(x,y) coordinates using Python Turtle?
On this trinket widget the turtle screen is 400 pixels wide by 400 pixels high. So:
- the top left corner coordinates are (-200,200)
- the top right corner coordinates are (200,200)
- the bottom left corner coordinates are (-200,-200)
- the bottom right corner coordinates are (200,-200)
- the centre of the screen coordinates are (0,0)
Look at the canvas below to understand how (x,y) coordinates work:
Challenge #1: Complete the code
We have started the code by creating a function called drawColumnChart(). This function takes five parameters – the values of the five columns to appear on the chart.
The code below shows you how to draw the first column. Your job consists of completing this code to draw all five columns.
Challenge #2: Line chart
Using a similar approach add a new function called drawLineChart() to draw a line chart using the same five values.
Challenge #3: Radar chart
Using a similar approach add a new function called drawRadarChart() to draw a radar chart using the same five values.