Question
use provided code and in python pls # create a rose curve in polar coordinates and # add widgets that can control the curve parameters
use provided code and in python pls
# create a rose curve in polar coordinates and
# add widgets that can control the curve parameters
# such as buttons and sliding bars
from matplotlib import pyplot as plt
from matplotlib.widgets import Slider, Button, RadioButtons
import numpy as np
def update(val):
# you may need to convert val into integers
pass
# main
fig = plt.figure(figsize=(8,8))
ax = fig.add_subplot(1, 1, 1, polar=True)
ax.set_title("Rose Curve", pad = 20)
n, d = 3, 9
# you may need to adjust the theta range and increase the resolution (600)
theta = np.linspace(0, d*16*np.pi, 600)
# you may need to convert negative values of r into positive values
r = np.cos(theta * n / d)
line, = ax.plot(theta, r, color='red')
plt.subplots_adjust(left=0.25, bottom=0.25)
slider1_ax = plt.axes([0.25, 0.15, 0.65, 0.03])
slider2_ax = plt.axes([0.25, 0.1, 0.65, 0.03])
slider1 = Slider(slider1_ax,'n value',0,13,valinit=n,valfmt="%i")
slider2 = Slider(slider2_ax,'d value',1,12,valinit=d,valfmt="%i")
slider1.on_changed(update)
slider2.on_changed(update)
plt.show()
Problem 1. A Rose Curve (5 points) Write a program that creates a rose curve in polar coordinates. You con read about the rose curve here: Rose (mathematics) - Wikipedia. You also need to add matplotlb widgets, two sliding bars that can control the curve parameters n and d. You can read about widgets here: 5 Ider Demo - Matplot 3.3.3 documentation and Gollery - Matplat lb 3.3.3 documentation (scroll down to the end of the page to the Widget Eramples). You can alsa use the partially implemented code an aur class Gnogle Colab. The rose curve parameters n and d define the angular frequency k, ( k=n /dd). Depending on the input value of n and d, your program should generate various rose curves shawn belaw
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started