Ask Your Question
1

Plotting Bessel function

asked 2012-09-30 11:07:31 +0100

R C gravatar image

updated 2024-04-14 16:06:44 +0100

FrédéricC gravatar image
plot(Bessel(0,'J'),0,10)

gives me a plot of the Bessel function. However:

plot(Bessel(0,'J'),0,10,color='red')

gives me an error:

TypeError: plot() got an unexpected keyword argument 'rgbcolor'

even though:

plot(sin,0,10,color='red')

works.

I am using the developmental version of sage. Any help to resolve this is appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2012-09-30 13:50:53 +0100

achrzesz gravatar image

updated 2012-09-30 15:09:40 +0100

plot(lambda x:bessel_J(0,x),(x,0,10),color='red')
#or 
plot(lambda x:Bessel(0,'J')(x),(x,0,10),color='red')
edit flag offensive delete link more

Comments

Thanks, this works well. By defining the lambda function outside the plot command, I can use it also in find_local_maximum and find_root. I will check the documentation to better understand why a lambda function is needed for the Bessel functions.

R C gravatar imageR C ( 2012-09-30 16:51:32 +0100 )edit
1

I think this is because the in the current implementation the Bessel functions define their own `plot` method and the options supported aren't the same as the top-level plot function. hopefully this can be improved sometime soon. It looks like it would be very easy to pass along a dictionary of options through the Bessel class's plot method: http://hg.sagemath.org/sage-main/file/d06cf4b2215d/sage/functions/special.py#l1176

benjaminfjones gravatar imagebenjaminfjones ( 2012-09-30 18:22:40 +0100 )edit

Thanks for clarifying this. So using a lambda function in the plot call allows for the standard options to be passed to the plot method.

R C gravatar imageR C ( 2012-10-01 06:18:49 +0100 )edit

@benjaminfjones - as you are certainly aware, making Bessel functions symbolic would also fix this - e.g. http://trac.sagemath.org/sage_trac/ticket/4102 for Bessel J.

kcrisman gravatar imagekcrisman ( 2012-10-01 09:18:52 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-09-30 11:07:31 +0100

Seen: 990 times

Last updated: Sep 30 '12