#20343: Adding sage/misc/tikz_picture.py
-------------------------+-------------------------------------------------
       Reporter:         |        Owner:
  slabbe                 |       Status:  needs_review
           Type:         |    Milestone:  sage-7.2
  enhancement            |   Resolution:
       Priority:  major  |    Merged in:
      Component:  misc   |    Reviewers:
       Keywords:         |  Work issues:
        Authors:         |       Commit:
  Sébastien Labbé        |  476b574c4198115e6e98e3396ed32f4b95077c35
Report Upstream:  N/A    |     Stopgaps:
         Branch:         |
  u/slabbe/20343         |
   Dependencies:         |
-------------------------+-------------------------------------------------
Description changed by slabbe:

Old description:

> Importing a file from my optional Sage package
> [https://github.com/seblabbe/slabbe slabbe-0.2.spkg] into Sage.
>
> {{{
> sage: from sage.misc.tikz_picture import TikzPicture
> sage: V =
> [[1,0,1],[1,0,0],[1,1,0],[0,0,-1],[0,1,0],[-1,0,0],[0,1,1],[0,0,1],[0,-1,0]]
> sage: P = Polyhedron(vertices=V).polar()
> sage: s = P.projection().tikz([674,108,-731],112)
> sage: t = TikzPicture(s)
> sage: t.pdf()
> }}}
>
> {{{
> sage: g = graphs.PetersenGraph()
> sage: s = latex(g)
> sage: t = TikzPicture(s, standalone_configs=["border=4mm"], packages
> =['tkz-graph'])
> sage: _ = t.pdf()
> }}}
>
> If dot2tex and graphviz available:
>
> {{{
> sage: t = TikzPicture.from_graph(g)  # optional: dot2tex
> }}}

New description:

 Importing `TikzPicture` class from my optional Sage package
 [https://github.com/seblabbe/slabbe slabbe-0.2.spkg] into Sage.

 One example:

 {{{
 sage: from sage.misc.tikzpicture import TikzPicture
 sage: V =
 [[1,0,1],[1,0,0],[1,1,0],[0,0,-1],[0,1,0],[-1,0,0],[0,1,1],[0,0,1],[0,-1,0]]
 sage: P = Polyhedron(vertices=V).polar()
 sage: s = P.projection().tikz([674,108,-731],112)
 sage: t = TikzPicture(s)
 sage: t.pdf()
 }}}

 Second example:

 {{{
 sage: g = graphs.PetersenGraph()
 sage: %time _ = TikzPicture(latex(g), standalone_configs=["border=4mm"],
 packages=['tkz-graph']).pdf()
 CPU times: user 3.52 ms, sys: 12.7 ms, total: 16.2 ms
 Wall time: 2.24 s
 }}}

 compared to using view (which crops the vertices and creates two pages pdf
 on mac):

 {{{
 sage: %time view(g, tightpage=True)
 CPU times: user 126 ms, sys: 85 ms, total: 211 ms
 Wall time: 6.06 s
 }}}

 Also, if dot2tex and graphviz available:

 {{{
 sage: t = TikzPicture.from_graph(g, prog='dot')  # optional: dot2tex
 }}}

--

--
Ticket URL: <http://trac.sagemath.org/ticket/20343#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to