Graphs not displaying?

113 views
Skip to first unread message

Juan Carlos Bustamante

unread,
Jan 13, 2015, 9:05:14 PM1/13/15
to sage-...@googlegroups.com
Hello,

I'm trying

D = DiGraph( { 0: [1,2,3], 1: [0,2], 2: [3], 3: [4], 4: [0,5], 5: [1] } )
show(D)

but it does not work. The error message says something about tikz not being installed. Is there any workarroud to display graphs within sagemathcloud (a sage worksheet)?

Hal Snyder

unread,
Jan 14, 2015, 3:38:58 AM1/14/15
to sage-...@googlegroups.com
Does this work?

D = DiGraph( { 0: [1,2,3], 1: [0,2], 2: [3], 3: [4], 4: [0,5], 5: [1] } )
D.show()

 

Juan Carlos Bustamante

unread,
Jan 14, 2015, 11:02:43 AM1/14/15
to sage-...@googlegroups.com
It does!
Thanks!

William Stein

unread,
Jan 16, 2015, 2:47:49 AM1/16/15
to sage-cloud
If you try restarting your project server (if it is currently
running), then refresh your browser, then try

D = DiGraph( { 0: [1,2,3], 1: [0,2], 2: [3], 3: [4], 4: [0,5], 5: [1] } )
show(D)

you may be very pleasantly surprised :-).

-- William
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud/3b954e4c-0584-417d-a0a9-5f23facda4cc%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Harald Schilly

unread,
Jan 16, 2015, 6:14:46 AM1/16/15
to sage-...@googlegroups.com
ha, cool! I think the arrows need to be a bit darker, but that's really nice.

h
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/CACLE5GAtxnpy4Goyd2FYLD%3DH2WSt2FA-JoV1R09OEJtvTE6zSA%40mail.gmail.com.

Hal Snyder

unread,
Jan 16, 2015, 8:28:17 AM1/16/15
to sage-...@googlegroups.com

you may be very pleasantly surprised :-).

 -- William

Very nice!

Of course, now I want to do vpython-style animations, like the planetary collision simulator at the end of week 8 of the edX class ANU-ASTRO1x (V8.6).

William Stein

unread,
Jan 16, 2015, 10:02:40 AM1/16/15
to sage-cloud
The graph plotting is a rewrite I did last night of Nathann cohen's
graph plotting code in sage...
It uses d3 -- http://d3js.org/ and I partly designed it via a sort of
d3-plugin framework, so it should be easy to add other d3
visualizations...

>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud/dc8cba48-4f41-4d8f-ab76-ce5718ec4a66%40googlegroups.com.

Juan Carlos Bustamante

unread,
Jan 16, 2015, 11:06:18 AM1/16/15
to sage-...@googlegroups.com
Really nice!

Is there a way to get the names of the vertices ? I tried what seemed to me the obvious possibilities, but did not work. Also, I was expecting that upon using the mouse wheel I could zoom in the graph, but this is not the case. How do I control the size of the figure?

JC


William Stein

unread,
Jan 16, 2015, 11:12:52 AM1/16/15
to sage-cloud, Nathann Cohen
On Fri, Jan 16, 2015 at 5:52 AM, Juan Carlos Bustamante
<jotac...@gmail.com> wrote:
> Really nice!
>
> I tried what seemed to me
> the obvious possibilities, but did not work. Also, I was expecting that upon
> using the mouse wheel I could zoom in the graph, but this is not the case.

Yep, definitely not (yet).

> How do I control the size of the figure?

Type this for the many options:

import graphics; graphics.graph_to_d3_jsonable?

In particular,

g=graphs.RandomLobster(9,.6,3)
show(g, width=300, height=300)

> Is there a way to get the names of the vertices ?

No, this isn't implemented. If anybody knows D3 and can suggest how to change

https://github.com/sagemath/sage/blob/master/src/ext/graphs/graph_plot_js.html

to add vertex labels, let me know!
> https://groups.google.com/d/msgid/sage-cloud/54B91780.9040404%40gmail.com.

Nathann Cohen

unread,
Jan 16, 2015, 12:36:31 PM1/16/15
to William Stein, sage-cloud
Hello,

>> I tried what seemed to me
>> the obvious possibilities, but did not work. Also, I was expecting that upon
>> using the mouse wheel I could zoom in the graph, but this is not the case.
>
> Yep, definitely not (yet).

I need help for that. I need help for that like for everything else: I
need people to help me by reviewing the patches, and for writing some
code too. Right now I stopped writing code just because there is
nobody to review the code that is already written. This is especially
true for documentation patches.

>> Is there a way to get the names of the vertices ?
>
> No, this isn't implemented. If anybody knows D3 and can suggest how to change
>
> https://github.com/sagemath/sage/blob/master/src/ext/graphs/graph_plot_js.html
>
> to add vertex labels, let me know!

There is a vertex_labels option in the graph gen_html_code function.
It will take its parameters from the show() call:

graphs.PetersenGraph().show(vertex_labels=True,method="js")

Nathann

William Stein

unread,
Jan 16, 2015, 1:13:16 PM1/16/15
to Nathann Cohen, sage-cloud

On Jan 16, 2015 9:36 AM, "Nathann Cohen" <nathan...@gmail.com> wrote:
>
> Hello,
>
> >> I tried what seemed to me
> >> the obvious possibilities, but did not work. Also, I was expecting that upon
> >> using the mouse wheel I could zoom in the graph, but this is not the case.
> >
> > Yep, definitely not (yet).
>
> I need help for that. I need help for that like for everything else: I
> need people to help me by reviewing the patches, and for writing some
> code too. Right now I stopped writing code just because there is
> nobody to review the code that is already written. This is especially
> true for documentation patches.
>

If my commercialization works succeeds I will be able to hire somebody fulltime to review (and coordinate reviewing of) trac tickets.

> >> Is there a way to get the names of the vertices ?
> >
> > No, this isn't implemented.  If anybody knows D3 and can suggest how to change
> >
> >    https://github.com/sagemath/sage/blob/master/src/ext/graphs/graph_plot_js.html
> >
> > to add vertex labels, let me know!
>
> There is a vertex_labels option in the graph gen_html_code function.
> It will take its parameters from the show() call:
>
> graphs.PetersenGraph().show(vertex_labels=True,method="js")
>

Nice.  Thanks!!
> Nathann

William Stein

unread,
Jan 16, 2015, 4:33:09 PM1/16/15
to Nathann Cohen, sage-cloud
>> There is a vertex_labels option in the graph gen_html_code function.
>> It will take its parameters from the show() call:
>>
>> graphs.PetersenGraph().show(vertex_labels=True,method="js")

vertex_labels should now be true by default in SMC (project server
restart, ya da)

William

Nathann Cohen

unread,
Jan 16, 2015, 10:21:59 PM1/16/15
to William Stein, sage-cloud
> vertex_labels should now be true by default in SMC (project server
> restart, ya da)

HMmm... It is a pity that you don't modify Sage instead, for things like this.

Nathann

William Stein

unread,
Jan 17, 2015, 12:57:43 AM1/17/15
to Nathann Cohen, sage-cloud

The pace of Sage development is way, way too slow for important stuff like this.

> Nathann

Nathann Cohen

unread,
Jan 17, 2015, 1:23:26 AM1/17/15
to William Stein, sage-cloud
> The pace of Sage development is way, way too slow for important stuff like
> this.

Can't you do both? Fix the problem with a Sage branch on a trac ticket
in needs_review, and merge that branch immediately in the version that
you run. When it will be merged into Sage you will not need it
anymore.

At a more personal level, I take your way of doings things very bad,
because it is like you don't care what happens to Sage for as long as
your code runs well... And I wonder why I should continue doing that
job if everybody is only thinking of his own interest.

I 'fixed' what I thought was the problem here in a ticket:
http://trac.sagemath.org/ticket/17646

It would be cool if you could review it.

Nathann
Message has been deleted

William Stein

unread,
Jan 17, 2015, 11:24:41 AM1/17/15
to sage-cloud
On Sat, Jan 17, 2015 at 1:28 AM, Dominique Laurain
<dominique...@orange.fr> wrote:
> [...] William's new code and
> mine too (for example: his new cloud code for 3D plots does'nt work on my
> laptop computer because old Fedora14 - i installed it to take care of the
> python stack limit - and old browser ..... and that's why I will code soon
> my "two-points persepective" kit)

I wasn't aware that the 3d plotting in SageMathCloud didn't work on
any platforms. It has a fully supported automatic fallback to canvas,
so should fully work on every modern browser except maybe opera mini:

http://caniuse.com/#feat=canvas

What browser are you having problems using 3d plotting on?

>
> It's sometimes the same for maths : only one problem but various solutions.
> For example, in graph theory, I like and learned so much since I bought
> Berge book ("Graphs and Hypergraphs"), there are many examples for that :
> from integer programming, enumeration, specific code.
>
> You'll never "code" (and walk) alone :-)

Thanks for the support.

I should respond to Nathann's remark "At a more personal level, I take
your way of doings things very bad, because it is like you don't care
what happens to Sage...". Like anybody who is not Nathann, I have a
different perspective than him on Sage. I also have long-term
not-completely-obvious strategies for improving Sage, which people may
not appreciate.

-- William

Dominique Laurain

unread,
Jan 18, 2015, 2:37:00 AM1/18/15
to sage-...@googlegroups.com
Hello William,

Funnily :  I deleted my post (because after thinking, I didn't want to write a "casus belli") ....too slow ... you had just enough time to read it. I guess you are connected at every minute to googlegoups :-)

My old operating system (Fedora 14) :

Linux  mypc 3.3.7-1.fc17.i686 #1 SMP Mon May 21 22:50:24 UTC 2012 i686 i686 i386 GNU/Linux

My old browser : Firefox 12.0   ... yes old, you wrote "should work on every modern browser" ... age is relative, and you just guess that every user upgrades his browser at full speed.

Changing my browser was not needed for me until now : when my Windows (Vista) crashed, I chose to install Linux, and since I wanted to use a local SAGE development, choose Fedora 14 because of python stack. I downloaded Fedora 12 soon after. Everything working at that time in the sagemath and in the sage cloud for 3D plot...

In the SAGE cloud I have now some issues : sometimes in core sage sometimes in graphics

# Implicite 3D plot - Ellipsoid
var ('x y z')
implicit_plot3d(x^2+4*y^2+9*z^2==36, (x,-6,6), (y,-6,6), (z,-6, 6), color="red", figsize=4, opacity=.3, axes="true" )

(x, y, z)
error rendering 3d scene -- Error loading THREE.js -- error loading -- ReferenceError: THREE is not defined
or

G = tetrahedron((0,-3.5,0), color='blue')
G.projection()
97 Error in lines 2-2 Traceback (most recent call last): File "/projects/6429970e-5a78-4aee-a6b1-af1e80542481/.sagemathcloud/sage_server.py", line 873, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> AttributeError: 'TransformGroup' object has no attribute 'projection'


Dominique




Reply all
Reply to author
Forward
0 new messages