Skip to content

Method tikz of polyhedron class can now return an object of type TikzPicture #33002

@seblabbe

Description

@seblabbe

As a follow up of #20343, the current branch now allows to specify the output type of the tikz method of a polyhedron:

sage: co = polytopes.cuboctahedron()
sage: t = co.tikz([674,108,-731], 112, output_type='TikzPicture')
sage: t
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}%
        [x={(0.249656cm, -0.577639cm)},
        y={(0.777700cm, -0.358578cm)},
        z={(-0.576936cm, -0.733318cm)},
        scale=1.000000,
---
92 lines not printed (5190 characters in total).
Use print to see the full content.
---
\node[vertex] at (1.00000, 0.00000, 1.00000)     {};
\node[vertex] at (1.00000, 1.00000, 0.00000)     {};
%%
%%
\end{tikzpicture}
\end{document}
sage: t.pdf()
'/tmp/tmpobwhg3p7/tikz_o9dkz419.pdf'

We also change the default behavior in favor of output_type='TikzPicture'. A deprecation warnings is now sent when output_type is not given:

sage: co = polytopes.cuboctahedron()
sage: t = co.tikz([674,108,-731], 112)
... DeprecationWarning: Since SageMath 5.13 (ticket #12083), the method
 .tikz() of a polyhedron returns an object of type ``LatexExpr`` which is a 
Python str. Since SageMath 9.7, this default behavior of returning an object
 of type LatexExpr is deprecated as the default output will soon change to 
an object of type ``TikzPicture`` from the module sage.misc.latex_standalone
 (newly introduced in SageMath 9.6). Please update your code to specify the
 desired output type as ``.tikz(output_type='LatexExpr')`` to keep the old
 behavior or ``.tikz(output_type='TikzPicture')`` to use the future default
 behavior.
See https://trac.sagemath.org/33002 for details.

CC: @trevorkarn @jplab

Component: graphics

Author: Sébastien Labbé

Branch: 8729071

Reviewer: Laith Rastanawi

Issue created by migration from https://trac.sagemath.org/ticket/33002

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions