plot(): no ticks and arrow on axes?

541 views
Skip to first unread message

Renato

unread,
Jan 30, 2011, 6:31:24 PM1/30/11
to sage-s...@googlegroups.com
Hello, I can't understand how the ticks option works in plot()... I
want to have no ticks or labels on the axis.

Also, is it possible to show the arrows on the axis? like this:
http://www.homeschoolmath.net/blog/few-complex-numbers.gif

I'm using latest version of sage

cheers
renato

Francois Maltey

unread,
Jan 30, 2011, 6:48:26 PM1/30/11
to sage-s...@googlegroups.com, Francois Maltey
Renato a �crit :

Search ticks and axes in plot? and copy/paste the examples :

plot(sin(pi*x), (x, -8, 8), ticks=[[],[]], axes=false)
+ arrow((-8,0),(8,0), color="black")
+ arrow((0,-1),(0,1), color="black")


If you want a grid add a function as

def grid (xmin, xmax, ymin, ymax) :
linesYcst = add (line ([(xmin, k), (xmax, k)]) for k in [ceil
(ymin).. floor(ymax)])
linesXcst = add (line ([(k, ymin), (k, ymax)]) for k in [ceil
(xmin).. floor(xmax)])
return linesXcst+linesYcst

read the help about line2d? and find the right options !

Then add to your (almost) last plot : ....+ grid ("the right area")

F.


Renato Budinich

unread,
Jan 31, 2011, 3:51:51 AM1/31/11
to sage-s...@googlegroups.com, Francois Maltey


On Mon, Jan 31, 2011 at 12:48 AM, Francois Maltey <fma...@nerim.fr> wrote:
Renato a écrit :

 
many thanks 

renato

Jason Grout

unread,
Jan 31, 2011, 7:31:43 AM1/31/11
to sage-s...@googlegroups.com
On 1/30/11 5:48 PM, Francois Maltey wrote:
> Renato a �crit :
>> Hello, I can't understand how the ticks option works in plot()... I
>> want to have no ticks or labels on the axis.
>>
>> Also, is it possible to show the arrows on the axis? like this:
>> http://www.homeschoolmath.net/blog/few-complex-numbers.gif
>>
>> I'm using latest version of sage
>
> Search ticks and axes in plot? and copy/paste the examples :
>
> plot(sin(pi*x), (x, -8, 8), ticks=[[],[]], axes=false)
> + arrow((-8,0),(8,0), color="black")
> + arrow((0,-1),(0,1), color="black")
>
>
> If you want a grid add a function as
>
> def grid (xmin, xmax, ymin, ymax) :
> linesYcst = add (line ([(xmin, k), (xmax, k)]) for k in [ceil (ymin)..
> floor(ymax)])
> linesXcst = add (line ([(k, ymin), (k, ymax)]) for k in [ceil (xmin)..
> floor(xmax)])
> return linesXcst+linesYcst


We also have gridlines implemented:

http://sagemath.org/doc/reference/sage/plot/plot.html#sage.plot.plot.Graphics.show

(see the gridline bullet point, or search the examples for "Add grid
lines at the major ticks of the axes." and the few examples following that)

Jason


Reply all
Reply to author
Forward
0 new messages