Try now in the
Open Cloud »
(no sign-in required)

# Heart and Flower Curves

Use polar plots to make natural-looking shapes.

Run the code to make a heart-like (cardioid) plot. Try values other than 0.5for example, 1 or 4:

PolarPlot plots curves in polar coordinates.

This plots the path of a point that has a constant distance of 1 unit from the origin as an angle sweeps from 0 to 360 degrees:

 In[1]:= XPolarPlot[1, {angle, 0 Degree, 360 Degree}]
 Out[1]=

Drag the slider to see how the curve is plotted:

 Out[1]=

This plots the path of a point whose distance from the origin is proportional to the angle:

 In[2]:= XPolarPlot[angle, {angle, 0 Degree, 360 Degree}]
 Out[2]=

Drag the slider to see how this curve is plotted:

 Out[2]=

This plots a heart shape (cardioid):

 In[3]:= XPolarPlot[1 - Sin[0.5 angle], {angle, 0 Degree, 360 Degree}]
 Out[3]=

Drag the slider to see how the cardioid is plotted:

 Out[3]=

 In[1]:= XPolarPlot[1 - Sin[0.5 angle], {angle, 0 Degree, 360 Degree}]
 Out[1]=

Allow the parameter to change. Drag the slider to get different shapes:

Hint: press (Windows) or (Mac) while dragging the slider for fine adjustment.

Note: click the + to the right of the slider to see the value of the parameter.

Add a slider to control the value of the parameter with Manipulate.

Replace the parameter 0.5 with the variable n, wrap the PolarPlot expression with Manipulate, and specify that n varies from 0 to 10, with an initial value of 0.5. Now you can drag the slider to change the value of the parameter:

 In[1]:= XManipulate[ PolarPlot[1 - Sin[n angle], {angle, 0 Degree, 360 Degree}], {{n, 0.5}, 0, 10} ]
 Out[1]=

Add a plot range to keep the plot from jumping around as you drag the slider:

 In[2]:= XManipulate[ PolarPlot[1 - Sin[n angle], {angle, 0 Degree, 360 Degree}, PlotRange -> 2], {{n, 0.5}, 0, 10} ]
 Out[2]=

 In[1]:= XManipulate[ PolarPlot[1 - Sin[n angle], {angle, 0 Degree, 360 Degree}, PlotRange -> 2], {{n, 0.5}, 0, 10} ]
 Out[1]=

Make the curve thick and red. Try other colors, like Blue or Green:

Hint: color names are capitalizedfor example, Purple, Gray, and Green.

PolarPlot normally draws a blue curve:

 In[1]:= XPolarPlot[1, {angle, 0 Degree, 360 Degree}]
 Out[1]=

You can change the color of the curve with PlotStyle:

 In[2]:= XPolarPlot[1, {angle, 0 Degree, 360 Degree}, PlotStyle -> Red]
 Out[2]=

Make the curve thicker with AbsoluteThickness. If there is more than one style element, put the elements in a list ({}):

 In[3]:= XPolarPlot[1, {angle, 0 Degree, 360 Degree}, PlotStyle -> {Red, AbsoluteThickness[5]}]
 Out[3]=

 In[1]:= XManipulate[ PolarPlot[1 - Sin[n angle], {angle, 0 Degree, 360 Degree}, PlotRange -> 2, PlotStyle -> {Red, AbsoluteThickness[5]}], {{n, 0.5}, 0, 10}]
 Out[1]=

Share ItMake an interactive website for exploring heart and flower curves:

Deploy the Manipulate to the Wolfram Cloud where anyone with a browser can use it:

 In[1]:= XCloudDeploy[ Manipulate[ PolarPlot[1 - Sin[n angle], {angle, 0 Degree, 360 Degree}, PlotRange -> 2, PlotStyle -> {Red, AbsoluteThickness[5]}], {{n, 0.5}, 0, 10}], Permissions -> "Public" ]
 Out[1]=

Click the link in the output to visit the site.

Share the link by right-clicking it and choosing Copy Address. Paste the link into an email, tweet, or other message.

 In[1]:= XCloudDeploy[ Manipulate[ PolarPlot[1 - Sin[n angle], {angle, 0 Degree, 360 Degree}, PlotRange -> 2, PlotStyle -> {Red, AbsoluteThickness[5]}], {{n, 0.5}, 0, 10}], Permissions -> "Public" ]
 Out[1]=