Skip to content
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

plotting -- fix vector plotting #1575

Closed
williamstein opened this issue Dec 20, 2007 · 7 comments
Closed

plotting -- fix vector plotting #1575

williamstein opened this issue Dec 20, 2007 · 7 comments

Comments

@williamstein
Copy link
Contributor

On Dec 19, 2007 12:24 PM, Jason Grout <> 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!  



-- William

Component: graphics

Issue created by migration from https://trac.sagemath.org/ticket/1575

@williamstein williamstein added this to the sage-2.9.2 milestone Dec 20, 2007
@jasongrout jasongrout self-assigned this Dec 21, 2007
@jasongrout
Copy link
Member

Attachment: vector-plot.patch.gz

@jasongrout
Copy link
Member

comment:3

In vector-plot.patch, plot is redefined to behave thusly:

  • the option "type" has values 'arrow', 'point', and 'step'
  • if 1 <= dimension <= 3, default type='arrow'
  • if dimension > 3, default type='step'

The old plot function was renamed plot_step.

@jasongrout jasongrout modified the milestones: sage-2.9.2, sage-2.9.1 Dec 21, 2007
@jasongrout
Copy link
Member

comment:5

I just discovered that Arrow has been changed to arrow3d in sage 2.9.3. The patch should be updated accordingly.

@jasongrout
Copy link
Member

Attachment: vector-plot-updated.patch.gz

@jasongrout
Copy link
Member

comment:6

I've renamed the "type" option to "plot_type" and fixed the Arrow issue (the graphics interface changed around 2.9.3) and the doctest "eps" issue.

The vector-plot-updated.patch should be applied instead of vector-plot.patch.

@sagetrac-cwitty
Copy link
Mannequin

sagetrac-cwitty mannequin commented Jan 27, 2008

comment:7

Looks good; doctests pass.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jan 27, 2008

comment:8

vector-plot-updated.patch merged in Sage 2.10.1.rc1.

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Jan 27, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants