William Stein wrote: > On Dec 19, 2007 12:24 PM, Jason Grout <[EMAIL PROTECTED]> wrote: >> I'm teaching linear algebra next semester and plan to use Sage. In >> trying the "obvious" way to plot a vector: >> >> sage: v=vector([1,2]) >> sage: v.plot().show() >> >> I get what looks like a step function of the coordinates. > > Yes, that's what it is. This is very useful, e.g., when using > vectors of data, computing Fourier transforms of them, etc. > And it works in arbitrary dimensions. > >> Instead, I >> have to do: >> >> sage: v=vector([1,2]) >> sage: arrow((0,0),v).show() >> >> which doesn't seem quite so natural to an undergraduate linear algebra >> student. First, is there an easier way to plot a vector (yes, I know I >> don't have to define v above and could just give the coordinates to >> arrow, but usually I'll be doing something with v as a vector)? Is it >> reasonable to redefine v.plot() to return the arrow for a vector with 3 >> or fewer dimensions, or is there some bigger reason to have things the >> way they are now? > > I think that would be bad, because it's potentially confusing and > unsystematic. However, the following -- which you will like -- > would be acceptable to me: > > Redefine v.plot() so for dimensions <= 3 it does what you describe above, > i.e., draws an arrow, but for dimensions >= 4 it gives an error message. > Then add an option to plot called "step", which if set to True restores > the current behavior. > > In fact, this was my intention all along, and somehow I screwed up. > The current plot signature for vectors is: > > def plot(self, xmin=0, xmax=1, eps=None, res=None, > connect=True, step=False, **kwds): > > Notice that step=False is already there! > > Anyway, this is now > http://trac.sagemath.org/sage_trac/ticket/1575
I've posted a patch implementing type='arrow', type='point', and type='step', with reasonable defaults for type based on the dimension. I think it's a good idea to have type='point'. For example, if you're plotting lots of vectors (illustrating linear combinations, for example), it's confusing to have lots of arrows that are overlapping. Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---