Phyllotaxis: Mathematical Programming Using R

Reia Natu
Analytics Vidhya

--

Phyllotaxis refers to the arrangement of leaves on a plant stem, forming distinctive spiral patterns of nature.

This article builds on this foundational concept to demonstrate how to draw ‘patterns of nature’ using mathematical concepts formulated in R. The scope of this article covers drawing the dandelion and the sunflower by employing the steps discussed further.

Pre-processing Steps:

Set an appropriate image size and load the ‘ggplot2’ package into the R environment.

Now, lets dive into the actual process of drawing flowers.

Step 1: Draw points on a circle

We will be using geom_point() for plotting the points in a 2D space.

Consider drawing 50 points on a circle having radius = 1.

Every (x,y) point is a unit circle iff x² + y² = 1.

Let us extend this to the Pythagorean trigonometric identity wherein

sin²(θ) + cos²(θ) = 1 for any real number θ.

The following code will apply this concept to generate a circle data plot of 50 points:

Step 2 : Use the concept of ‘The Golden Angle’

Plants arrange their leaves in a spiral pattern. In the plot generated in Step 1, all the points are at the same distance from the origin. To get them into a spiral pattern, we can multiply x and y by a factor increasing for each of the points. Let ‘t’ be this factor satisfying the requirement and let us make it harmonious using The Golden Angle.

Golden Angle = π(3 − √5). Imagine breaking up the circumference of a circle into two arcs with lengths a and b with such that a>b. The angle that breaks the circle such that a/b= (a+b)/a is called the Golden Angle.

Here, the Golden Angle is the angle subtended by the smaller (red) arc.

Let us now spiralize 500 points using the following code and see the result.

Step 3: Remove unnecessary things from the plot

Let us clean up the previous plot by keeping only the desired part of the visual by removing:

  1. The grey background
  2. the grid of vertical and horizontal lines
  3. the title on each axis
  4. the ticks along each axis
  5. the text label along the axes

After doing the needful, we get the plot as seen below:

Step 3: Visualize the Dandelion and the Sunflower

By playing around with the ‘alpha’, ‘shape’ and ‘color’ parameters that determine size, transparency, and color of the points, find out how we get patterns of the Dandelion and the Sunflower right below!

Thus, we have successfully seen how to draw floral patterns using Mathematics in R.

It is important to note that these patterns are very sensitive to the angle between the points that form the spiral. Small changes to the angle can generate significantly different images!

--

--

Reia Natu
Analytics Vidhya

Data Scientist | 15K+ Data Science Family on Instagram @datasciencebyray | LinkedIn- https://in.linkedin.com/in/reia-natu-59638b31a |