Open nthiery opened 12 years ago
Attachment: trac_13232-plot_latex-nt.patch.gz
First draft written by three students of mine. More details to come after dinner :-)
Oh wow, this would be cool. Now I don't know which would look better - SageTeX with sageplot
environment or this?
Author: Thomas Ayoub, Bertheville Chloé, Arthur Mauvezin
Attachment: alcove.png
A sage plot
Attachment: alcove.tex.gz
The TeX produced from it (with a little manual tweak)
The pdf obtained by compiling the TeX
Attachment: alcove.pdf.gz
As an example, I attached the result of using this patch on the following plot::
sage: L = RootSystem(['A',2,1]).weight_space()
sage: P = L.plot(size=[[-1..1],[-1..1]],alcovewalks=[[0,2,0,1,2,1,2,0,2,1]]); P
I had to tweak a tiny bit the latex, for tikz crashes with an arithmetic error when given the option color={rgb: red,0;green,0;blue,0}
. Otherwise, I guess that using
sage: view(P)
would have worked.
Anyway, it would be best to use named colors instead, and not to repeat opacity=1 all the time.
Some minor comments:
_latex
method to GraphicsPrimitive
and override that from the arc
, line
, etc? I think this method is used only in Graphics
so that only one \begin{tikzpicture}
is used, right? Since the classes Arc
, Line
, etc are not exposed hence it doesn't seem to matter whether the method is named latex
or _latex
. I am not sure which is the correct approach here, so I am just curious.Graphics
if there are no objects in it? Again, I am just wondering because I am not sure which behavior is more appropriate. Currently, this patch results in the following behavior:sage: G = Graphics()
sage: latex(G)
\begin{tikzpicture}
\end{tikzpicture}
sage: len(G)
0
None
should be done by using is
or is not
, according to this PEP.Replying to @ppurka:
Some minor comments:
- Is it necessary or useful to add
_latex
method toGraphicsPrimitive
and override that from thearc
,line
, etc? I think this method is used only inGraphics
so that only one\begin{tikzpicture}
is used, right? Since the classesArc
,Line
, etc are not exposed hence it doesn't seem to matter whether the method is namedlatex
or_latex
. I am not sure which is the correct approach here, so I am just curious.
In any cases, all the methods should be named _latex_
, for consistency with SageObject. At this point, I don't see a use for having _latex_
in GraphicsPrimitive, since there is already a default (admittedly pretty useless in this case) implementation in SageObject.
- Should it return an empty string from
Graphics
if there are no objects in it? Again, I am just wondering because I am not sure which behavior is more appropriate. Currently, this patch results in the following behavior:sage: G = Graphics() sage: latex(G) \begin{tikzpicture} \end{tikzpicture} sage: len(G) 0
That's sounds reasonable; let's not introduce a special case.
- The check for
None
should be done by usingis
oris not
, according to this PEP.
+1
Thanks for your comments!
Chloe, Thomas, Arthur,
Are you planning to work further on this patch?
If not, any volunteer to take on this project?
In some ways, this is already handled by matplotlib's PGF export, but I think it would still be good to have a native (and more compact) version of the graphics objects (in particular, so it doesn't go through show
, need to create a temp file, and come with all of the "standard" plot things).
Implement latex methods for plots to produce latex/tikz pictures.
CC: @dandrake @jhpalmieri @kcrisman bertheville.chloe@club-internet.fr thomas.ayoub@u-psud.fr arthur.mauvezin@u-psud.fr @tscrim
Component: graphics
Keywords: latex, plot
Author: Thomas Ayoub, Bertheville Chloé, Arthur Mauvezin
Issue created by migration from https://trac.sagemath.org/ticket/13232