Python Challenge 1 - concertina

Hints for Python Challenge 1

  • If you are having difficulties plotting a circle, try plotting a simple function first and build up to more complex functions. For example, maybe try plotting the straight line y = 2x + 1 first, or the quadratic y = x2 − 1.
     
  • When you are plotting the circle, the parameter t needs to be chosen. Usually this is chosen as an array. Such a array can be set up using the numpy.linspace command.
     
  • The equation describing Fermat’s Spiral is given by

    y = ±t1/2 sin(t)
    x = ±t1/2 cos(t)

    (where ± means that one part of the spiral uses + and one uses −). Can you work out how to plot the curve using just one plot command?
     

  • The equation describing the Butterfly Curve includes the exponential function. This function is coded within numpy as numpy.exp. Also, the number π can be obtained using numpy.pi.

Notes

In the figures plotted above, a number of Colormaps have been used to vary the colour of the line segments as a function of position. Different maps have different purposes - some are smoothly graded from light to dark, while others only appear as discrete colours.

Solution for Python Challenge 1