markers for list_plot

75 views
Skip to first unread message

zeynep

unread,
Jan 24, 2008, 10:29:36 PM1/24/08
to sage-newbie
Hello,
I need to use superimposed list_plot functions, but I couldn't find a
way to choose a marker other than points. The graphs will eventually
go into a black and white document, so I cannot just change the
colors.
Thanks in advance!
Zeynep

Hector Villafuerte

unread,
Jan 25, 2008, 3:40:37 PM1/25/08
to sage-...@googlegroups.com
Zeynep,
I tried this out on SAGE notebook:

s0 = [(k-10)^2 for k in range(10)]
s1 = [k^2 for k in range(10)]
list_plot(s0) + list_plot(s1, linestyle='-.')

which returned this warning:

"The allowed options for Point set defined by 10 point(s) are:
alpha How transparent the line is.
faceted If True color the edge of the point.
hue The color given as a hue.
pointsize How big the point is.
rgbcolor The color as an rgb tuple."

Then I tried this:
list_plot(s0) + list_plot(s1, pointsize="25")

which makes them distinguishable, though not a very elegant solution I
have to admit (I'm a SAGE newbie myself :)
Best,
--
Hector

Jacob Hicks

unread,
Jan 25, 2008, 4:45:14 PM1/25/08
to sage-...@googlegroups.com
The list_plot function just passes the argument string you provide
straight to the point method. Since those are the options for point,
that is all list_plot can do.

R has very powerfully plotting ability. For your particular problem, try:

from rpy import r
r.png(os.curdir+'/sage.png')
r.par(ann=0)
s0 = [float((k-10)^2) for k in range(10)]
s1 = [float(k^2) for k in range(10)]
r.plot(s0, pch="+")
r.points(s1, pch="*")
_ = r.dev_off()

(WARNING: this only works if you have X11 headers on the computer
running the sage server.If you do not replace png with postscript.
That works an all servers I have tried but won't show up in the
notebook.)

Hope that helps.

Jacob

zeynep

unread,
Jan 26, 2008, 4:17:16 PM1/26/08
to sage-newbie
Thanks Jacob, I'll try this. In the worst case, I'll switch back to
Mathematica.

Hector, your suggestion is also good (especially for a homework or
something like that) but unfortunately it'd fail to satisfy my advisor
for graphs that'll go into a journal article... :)

Thank you for your time!

Zeyenp

Hector Villafuerte

unread,
Feb 3, 2008, 10:19:39 PM2/3/08
to sage-...@googlegroups.com, zkirk...@gmail.com
Hi,
I've just noticed that matplotlib's support within SAGE is pretty
good. Based on this:
http://sagemath.org/doc/html/const/node16.html

I tried this out:

s0 = [[k,(k-10)^2] for k in range(10)]
s1 = [[k,k^2] for k in range(10)]
p0 = line(s0, linestyle='--')
p1 = line(s1, linestyle=':')
p = p0 + p1
p.show()

Best,
--
Hector

Reply all
Reply to author
Forward
0 new messages