Ticket #7850 (closed enhancement: invalid)

Opened 3 years ago

Last modified 3 years ago

spherical plot

Reported by: olazo Owned by: olazo
Priority: minor Milestone: sage-duplicate/invalid/wontfix
Component: graphics Keywords: spherical,plot
Cc: Work issues:
Report Upstream: N/A Reviewers:
Authors: olazo Merged in:
Dependencies: Stopgaps:

Description (last modified by olazo) (diff)

This command is now supposed to be derived from the code in this ticket #7872

Attachments

docstring Download (966 bytes) - added by olazo 3 years ago.
a proposal for a docstring

Change History

comment:1 Changed 3 years ago by jason

Here is a rough cut of a generic function:  http://sagenb.org/home/pub/1322/

# TODO: figure out a way to determine if f is an expression or callable symbolic function for the if statement.

def make_coordinate_plot3d(transformation, function_variable,parameter_variables):
   def new_plot(f, var1_range, var2_range,**kwds):
       f_is_expression=True
       
       if f_is_expression:
           # if f is an expression, then we can use .subs.  This is faster, because parametric_plot3d
           # can then use fast_float
           if len(var1_range)==3:
               vars=[var1_range[0], var2_range[0]]
           else:
               vars=sage.symbolic.ring.var('v1,v2')
           plot_func=[t.subs({function_variable:f, parameter_variables[0]:vars[0], parameter_variables[1]:vars[1]})
                       for t in transformation]
       else:
           # if f is not a symbolic expression or function, use the following
           # We could make this faster by using fast_float on the components of transformation
           # We need to do the function and map instead of just a list comprehension because
           # of python scoping; see http://lackingrhoticity.blogspot.com/2009/04/python-variable-binding-semantics-part.html
           def subs_func(t):
               return lambda x,y: t.subs({function_variable:f(x,y), parameter_variables[0]:x, parameter_variables[1]:y})
           plot_func=map(subs_func,transformation)

       return parametric_plot3d(plot_func, var1_range, var2_range,**kwds)
   return new_plot 

 	
var('r,t,p') 
jason_spherical_plot3d=make_coordinate_plot3d([r*cos(t)*sin(p), r*sin(t)*sin(p), r*cos(p)], function_variable=r, parameter_variables=[t,p]) 

comment:2 Changed 3 years ago by jason

Here's the relevant sage-devel thread:  http://groups.google.com/group/sage-devel/browse_thread/thread/8e38cdd8048eb39c

Thanks again for working on this!

Here are some comments about the implementation up at  http://www.sagenb.org/home/pub/1323/, just based on reading the code.

  1. To be consistent with the plotting functions, it would also need to support something like:
spherical_plot3d(lambda x,y: x+y, (0,2*pi), (0,pi))

That's the purpose behind the convoluted second half of the make_coordinate_plot3d function (because symbolic functions can't be multiplied by lambda functions).

  1. It's better to use "zran is None" rather than "zran==None". It's a much faster test.
  1. There is still some dependence on variable names if the variable name is not specified. This should give an error, or at least a deprecation warning, as it is no longer a supported syntax for plotting:
spherical_plot3d(phi*theta, (0,2*pi),(0,pi))

(note that the expression has two variables, but I haven't said which variable corresponds to which range. This is particularly confusing with spherical plots, since there are two opposite conventions.

  1. except statements should catch specific exceptions (e.g., "except ValueError?"), instead of just triggering on any error.
  1. I'm not sure there's any difference between the transform_plot3d and just plainly calling parametric_plot3d. transform_plot3d seems to just basically be a rename of parametric_plot3d.

comment:3 Changed 3 years ago by olazo

  • Status changed from new to needs_review
  • Description modified (diff)

comment:4 Changed 3 years ago by olazo

  • Owner changed from was to olazo

comment:5 Changed 3 years ago by olazo

  • Status changed from needs_review to needs_work
  • Description modified (diff)

comment:6 Changed 3 years ago by jason

See also #7850 for a cylindrical plotting function

comment:7 Changed 3 years ago by olazo

  • Description modified (diff)

comment:8 Changed 3 years ago by olazo

  • Description modified (diff)

Changed 3 years ago by olazo

a proposal for a docstring

comment:9 Changed 3 years ago by olazo

  • Status changed from needs_work to closed
  • Resolution set to invalid
  • Description modified (diff)

comment:10 Changed 3 years ago by mvngu

  • Milestone set to sage-duplicate/invalid/wontfix
Note: See TracTickets for help on using tickets.