# Plotting Bessel function

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 close merge delete

Sort by ยป oldest newest most voted
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')
more

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.

( 2012-09-30 09:51:32 -0500 )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

( 2012-09-30 11:22:40 -0500 )edit
( 2012-09-30 11:27:31 -0500 )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.

( 2012-09-30 23:18:49 -0500 )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.

( 2012-10-01 02:18:52 -0500 )edit