Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to deal with 2d plots?

sage: P = polygon([(0,0),(5,0),(3,3)])
sage: list(P) ; list(P[0])

[Polygon defined by 3 points]
[(0.0, 0.0), (5.0, 0.0), (3.0, 3.0)]

Looks fine, but this will not work with a circle:

sage: C = circle((0,0),5)
sage: list(C) ; list(C[0])

[Circle defined by (0.0,0.0) with r=5.0]
Traceback (click to the left of this block for traceback)
...
TypeError: 'Circle' object is not iterable

Embedding a 2d plot into a 3d plot seems to help:

sage: C = circle((0,0),5)
sage: C3 = C.plot3d()
sage: C3.jmol_repr(C3.default_render_params())

[[['draw line_1 diameter 1 curve {5.0 0.0 0.0}  {4.96057350657
0.626666167822 0.0}  {4.84291580564 1.24344943582 0.0}  {4.64888242944
1.84062276342 0.0}  {4.38153340022 2.40876837051 0.0}  {4.04508497187
2.93892626146 0.0}   ...

There are different representations: json_repr , jmol_repr , tachyon_repr (depending on the viewer). I don't know why, but in the case of C3 json_repr returns an empty list, so I switched to jmol_repr.