On 2013-06-19, Emmanuel Charpentier <emanuel.charpent...@gmail.com> wrote:
> ------=_Part_3454_23024622.1371674663187
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable
>
> Dear Dmitrii, dear list,
>
> Following Dmitrii hints, I tried latex(H). It turns out that the curved=20
> edges are a feature, not a bug (a better look at the GraphLatex page showed=
>=20
> me explicit documentation about this). This design choice seems embedded in=
>=20
> the source code for latex generation of directed graphs, and there exist=20
> (currently) no option for changing it (no sage-settable parameter for=20
> edge_style and arrowheads). Too bad the result is ugly as sin...
>
> I could hack a new style for DiGraphs. I could also hack the code and make=
>=20
> these parameters tunable. Both of these options are lengthy, and my=20
> RealLife(TM) constraints make them a bit difficult. It seems faster to=20
> either a) hack convenient parameters to ....DiGraph.plot and generate a PDF=
>=20
> or b) directly generate tikz code from the graph specifications.
>
> This bit of ad-hockery is probably the only way I can cope with my current=
>=20
> problem. Bit I think a better solution would be to rewrite (part of) the=20
> GraphLatex specification to give them more degree of freedom.
>
> Looking at the Trac tickets for this subject hnted that such a task is=20
> probably not easy. So I won't, for now, create  new ticket. I'll have to=20
> look first at the source code for GraphLatex (wich I haven't yet located,=
>=20
> shame on me...).

it is in sage/graphs/graph_latex.py

>
>                                                                    Emmanuel=
>=20
> Charpentier
>
> BTW : tex.stackexchange.com gave me few hints about this problem : people=
>=20
> here tend to hack their solutions directly in \LaTeX, or even in plain \TeX=
>=20
> (God forbid...).
>
> Le lundi 17 juin 2013 22:03:32 UTC+2, Dima Pasechnik a =E9crit :
>>
>> On 2013-06-17, Emmanuel Charpentier <emanuel.c...@gmail.com <javascript:>=
>>=20
>> wrote:=20
>> > ------=3D_Part_260_31328394.1371497392901=20
>> > Content-Type: text/plain; charset=3DISO-8859-1=20
>> >=20
>> > Dear list,=20
>> >=20
>> > I am trying to render a *directed* graph with LaTeX and tikz. I'ts a=20
>> > Bayesian network based on some causal reasoning (hence the necessity fo=
> r=20
>> a=20
>> > directed graph), but I'll reduce my problem to a simple test case.=20
>> >=20
>> > The following code :=20
>> >=20
>> > var("a", latex_name=3D"\mathrm{a}")=20
>> > var("b", latex_name=3D"\mathrm{b}")=20
>> > var("c", latex_name=3D"\mathrm{c}")=20
>> > var("d", latex_name=3D"\mathrm{d}")=20
>> > var("e", latex_name=3D"\mathrm{e}")=20
>> > H=3DDiGraph({a:{b:'$\\beta_{a,b}$',c:'$\\beta_{a,c}$',d:'$\\beta_{a,d}$=
> '},=20
>> > c:{e:'$\\beta_{c,e}$'}})=20
>> > H.set_pos(H.layout_acyclic())=20
>> > H.set_latex_options(tkz_style=3D"Custom", graphic_size=3D(4,4),=20
>> > vertex_size=3D0.5, vertex_labels=3DTrue, edge_labels=3DTrue,=20
>> > edge_label_sloped=3DFalse)=20
>> > view(H)=20
>> >=20
>> > gives me *almost* what I want (drag-and-drop from a notebook] :=20
>> >=20
>> >=20
>> > The graph has the desired layout, the markup (vertices and edges) is=20
>> > correct. But, for reasons I haven't be able to fathom,  edges are=20
>> rendered=20
>> > as circle arcs (about pi/6). It is not especially good in my test case,=
>=20
>> and=20
>> > makes my full graph positively awful...=20
>> >=20
>> > Trying to use another style of graph makes me lose [a) edge markup=20
>> and/or=20
>> > b) vertex markup], and c) arrow heads. Looking in the documentation=20
>> about=20
>> > arrow heads gave no clue. Trying to specify latex parameters for edges=
>=20
>> and=20
>> > vertices has no point, since these setups are forgotten by the new styl=
> e=20
>> > (and yes, I tried to use two set_latex_options instructions : same=20
>> results=20
>> > in both orders...).=20
>> >=20
>> > Any hint ?=20
>> Your subject says that you narrowed down the problem to LaTeX/tikz. If=20
>> so, try a forum frequented by tikz wizards,=20
>> e.g. http://tex.stackexchange.com/=20
>>
>> Anyhow, I'd try to use sagetex to draw your graph, generating LaTeX file=
>=20
>> along=20
>> the way. Maybe then it would be more clear how to tweak the drawing.=20
>>
>> HTH,=20
>> Dmitrii=20
>>
>>
>>
>> >=20
>> >                                                 Emmanuel Charpentier=20
>> >=20
>>
>>
>
> --=20
> You received this message because you are subscribed to the Google Groups "=
> sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> ------=_Part_3454_23024622.1371674663187
> Content-Type: text/html; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable
>
> Dear Dmitrii, dear list,<div><br></div><div>Following Dmitrii hints, I trie=
> d latex(H). It turns out that the curved edges are a feature, not a bug (a =
> better look at the GraphLatex page showed me explicit documentation about t=
> his). This design choice seems embedded in the source code for latex genera=
> tion of directed graphs, and there exist (currently) no option for changing=
>  it (no sage-settable parameter for edge_style and arrowheads). Too bad the=
>  result is ugly as sin...</div><div><br></div><div>I could hack a new style=
>  for DiGraphs. I could also hack the code and make these parameters tunable=
> . Both of these options are lengthy, and my RealLife(TM) constraints make t=
> hem a bit difficult. It seems faster to either a) hack convenient parameter=
> s to ....DiGraph.plot and generate a PDF or b) directly generate tikz code =
> from the graph specifications.</div><div><br></div><div>This bit of ad-hock=
> ery is probably the only way I can cope with my current problem. Bit I thin=
> k a better solution would be to rewrite (part of) the GraphLatex specificat=
> ion to give them more degree of freedom.</div><div><br></div><div>Looking a=
> t the Trac tickets for this subject hnted that such a task is probably not =
> easy. So I won't, for now, create &nbsp;new ticket. I'll have to look first=
>  at the source code for GraphLatex (wich I haven't yet located, shame on me=
> ...).</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
> bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
> ; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Emmanuel Charpentier</div><div><=
> br></div><div>BTW : tex.stackexchange.com gave me few hints about this prob=
> lem : people here tend to hack their solutions directly in \LaTeX, or even =
> in plain \TeX (God forbid...).<br><br>Le lundi 17 juin 2013 22:03:32 UTC+2,=
>  Dima Pasechnik a =E9crit&nbsp;:<blockquote class=3D"gmail_quote" style=3D"=
> margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;=
> ">On 2013-06-17, Emmanuel Charpentier &lt;<a href=3D"javascript:" target=3D=
> "_blank" gdf-obfuscated-mailto=3D"gdW3cqa1SREJ">emanuel.c...@gmail.com</a><=
> wbr>&gt; wrote:
><br>&gt; ------=3D_Part_260_31328394.<wbr>1371497392901
><br>&gt; Content-Type: text/plain; charset=3DISO-8859-1
><br>&gt;
><br>&gt; Dear list,
><br>&gt;
><br>&gt; I am trying to render a *directed* graph with LaTeX and tikz. I'ts=
>  a=20
><br>&gt; Bayesian network based on some causal reasoning (hence the necessi=
> ty for a=20
><br>&gt; directed graph), but I'll reduce my problem to a simple test case.
><br>&gt;
><br>&gt; The following code :
><br>&gt;
><br>&gt; var("a", latex_name=3D"\mathrm{a}")
><br>&gt; var("b", latex_name=3D"\mathrm{b}")
><br>&gt; var("c", latex_name=3D"\mathrm{c}")
><br>&gt; var("d", latex_name=3D"\mathrm{d}")
><br>&gt; var("e", latex_name=3D"\mathrm{e}")
><br>&gt; H=3DDiGraph({a:{b:'$\\beta_{a,b}<wbr>$',c:'$\\beta_{a,c}$',d:'$\\<=
> wbr>beta_{a,d}$'},=20
><br>&gt; c:{e:'$\\beta_{c,e}$'}})
><br>&gt; H.set_pos(H.layout_acyclic())
><br>&gt; H.set_latex_options(tkz_style=3D<wbr>"Custom", graphic_size=3D(4,4=
> ),=20
><br>&gt; vertex_size=3D0.5, vertex_labels=3DTrue, edge_labels=3DTrue,=20
><br>&gt; edge_label_sloped=3DFalse)
><br>&gt; view(H)
><br>&gt;
><br>&gt; gives me *almost* what I want (drag-and-drop from a notebook] :
><br>&gt;
><br>&gt;
><br>&gt; The graph has the desired layout, the markup (vertices and edges) =
> is=20
><br>&gt; correct. But, for reasons I haven't be able to fathom, &nbsp;edges=
>  are rendered=20
><br>&gt; as circle arcs (about pi/6). It is not especially good in my test =
> case, and=20
><br>&gt; makes my full graph positively awful...
><br>&gt;
><br>&gt; Trying to use another style of graph makes me lose [a) edge markup=
>  and/or=20
><br>&gt; b) vertex markup], and c) arrow heads. Looking in the documentatio=
> n about=20
><br>&gt; arrow heads gave no clue. Trying to specify latex parameters for e=
> dges and=20
><br>&gt; vertices has no point, since these setups are forgotten by the new=
>  style=20
><br>&gt; (and yes, I tried to use two set_latex_options instructions : same=
>  results=20
><br>&gt; in both orders...).
><br>&gt;
><br>&gt; Any hint ?
><br>Your subject says that you narrowed down the problem to LaTeX/tikz. If
><br>so, try a forum frequented by tikz wizards,=20
><br>e.g. <a href=3D"http://tex.stackexchange.com/"; target=3D"_blank">http:/=
> /tex.stackexchange.com/</a>
><br>
><br>Anyhow, I'd try to use sagetex to draw your graph, generating LaTeX fil=
> e along
><br>the way. Maybe then it would be more clear how to tweak the drawing.
><br>
><br>HTH,
><br>Dmitrii
><br>
><br>
><br>
><br>&gt;
><br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
> sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
> nbsp; &nbsp; &nbsp; &nbsp; Emmanuel Charpentier
><br>&gt;
><br>
><br></blockquote></div>
>
><p></p>
>
> -- <br />
> You received this message because you are subscribed to the Google Groups &=
> quot;sage-support&quot; group.<br />
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to sage-support+unsubscr...@googlegroups.com.<br />
> To post to this group, send email to sage-support@googlegroups.com.<br />
> Visit this group at <a href=3D"http://groups.google.com/group/sage-support"=
>>http://groups.google.com/group/sage-support</a>.<br />
> For more options, visit <a href=3D"https://groups.google.com/groups/opt_out=
> ">https://groups.google.com/groups/opt_out</a>.<br />
> &nbsp;<br />
> &nbsp;<br />
>
> ------=_Part_3454_23024622.1371674663187--
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to