-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't graph trigonometric function of secx, cscx, cotx, tanx,... #694
Comments
Those functions are discontinuous, you must break them into pieces to make them work, like this. Also you can import the math package of python instead numpy. |
Thanks very much, but it didn't work... and how to import the math package of python instead numpy.... and |
This is not a programming problem, the problem is that you do not know about trig functions. The tangent function is discontinuous in PI/2 + n*PI, so you should break it to pieces at those intervals. No, you don't need to uninstall numpy, you just have to import math as a module. If you want to use manim you need to have basic programming knowledge in python, so read the documentation if you don't know what you are doing. This is one way to do it: class TanGraph(GraphScene):
CONFIG = {
"y_max" : 10,
"y_min" : -10,
"x_max" : 5,
"x_min" : -5,
"graph_origin" : ORIGIN,
}
def construct(self):
self.setup_axes()
tan_function = lambda x: np.tan(x)
tan_graph = VGroup()
approx_factor = 0.934
for n in range(-1,2):
graph = self.get_graph(tan_function,
color = RED,
x_min = (-PI/2)*approx_factor+n*PI,
x_max = (PI/2)*approx_factor+n*PI
)
tan_graph.add(graph)
self.play(
ShowCreation(tan_graph),
)
self.wait() |
|
thanks a looooooot.... i think i just made a really stupid question....😂 |
See my 2D graph tutorial in GitHub |
thanks .... |
source code:
class PlotFunctions(GraphScene):
CONFIG = {
"x_min" : -10,
"x_max" : 10.3,
"y_min" : -1.5,
"y_max" : 1.5,
"graph_origin" : ORIGIN ,
"function_color" : RED ,
"axes_color" : GREEN,
"x_labeled_nums" :range(-10,12,2),
I replaced "return np.cos(x)" to "return np.tan(x)"...i got this:
![image](https://user-images.githubusercontent.com/36161299/63267544-e140a700-c2c4-11e9-9164-a14d37ee8673.png)
and then I replaced "return np.cos(x)" to "return np.sec(x)/cot(x)/csc(x)"...i got this:
AttributeError: module 'numpy' has no attribute 'sec'...
The text was updated successfully, but these errors were encountered: