I need to generate a table based on what r equals at different theta values.
I am easily able to graph and show the equation with matplotlib, and was hoping that there was an easy way to:
give numpy the theta variable, my curve equation, and viola, return the r value
I tried to look at the documentation of numpy but am having a hard time finding what I need.
import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np mpl.style.use('default') # Number of Points Ploted # Change this numer to affect accuracy of the graph n = 3000 theta = np.linspace(0, 2.0*np.pi, n) def show_grid(): plt.grid(True) plt.legend() plt.show() # Setting the range of theta to [0, 2π] for this specific equation theta4 = np.linspace(0, 2*np.pi, n) # Writing the equation curve4 = 5*np.cos(64*theta) ax1 = plt.subplot(111, polar=True) ax1.plot(theta4, curve4, color='xkcd:cyan', label='CURVE 4: r = 5cos(64θ), [0, 2π)') ax1.set_ylim(0,5) ax1.set_yticks(np.linspace(0,5,6)) show_grid()
The above code produces a graph nicely, but:
Can I use the same variables to return r at theta?