ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 30 Dec 2015 21:23:21 +0100How to plot lattice paths ?https://ask.sagemath.org/question/31910/how-to-plot-lattice-paths/I have seen that the command
for D in DyckWords(n):
D.pretty_print(type="NE-SE")
gives a nice plot of all Dyck paths.
Is there an analogous command for the set of all 2^n lattice paths of length n with up- and downsteps of height 1? Please give details, I am a newcomer to Sage.
Edit: Sorry if my question is not properly formulated. Perhaps I should modify my question somewhat:
The command
D = DyckWords(6)[3]
D.pretty_print(type="NE-SE")
gives a nice picture (which I unfortunately cannot copy)
of the Dyckpath corresponding to [1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0]
by interpreting 0 with a down-step and 1 with an up-step.
How can I print a corresponding picture for a word which corresponds to a path with negative values?
Tue, 29 Dec 2015 09:30:07 +0100https://ask.sagemath.org/question/31910/how-to-plot-lattice-paths/Answer by slelievre for <p>I have seen that the command</p>
<pre><code>for D in DyckWords(n):
D.pretty_print(type="NE-SE")
</code></pre>
<p>gives a nice plot of all Dyck paths. </p>
<p>Is there an analogous command for the set of all 2^n lattice paths of length n with up- and downsteps of height 1? Please give details, I am a newcomer to Sage.</p>
<p>Edit: Sorry if my question is not properly formulated. Perhaps I should modify my question somewhat:
The command</p>
<pre><code>D = DyckWords(6)[3]
D.pretty_print(type="NE-SE")
</code></pre>
<p>gives a nice picture (which I unfortunately cannot copy)
of the Dyckpath corresponding to [1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0]
by interpreting 0 with a down-step and 1 with an up-step.</p>
<p>How can I print a corresponding picture for a word which corresponds to a path with negative values?</p>
https://ask.sagemath.org/question/31910/how-to-plot-lattice-paths/?answer=31918#post-id-31918Here is how you could explore this question.
sage: DD = DyckWords(11)
sage: D = DD.an_element()
sage: D
[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]
sage: D.pretty_print(type="NE-SE")
/\/\/\/\/\/\/\/\/\/\/\
Documentation:
sage: D.pretty_print?
Source code:
sage: D.pretty_print??
We see that the source code calls `self._repr_lattice()`
so we check out the documentation for this method:
sage: D._repr_lattice?
and the source code:
sage: D._repr_lattice??
and check if we can adapt it to other lattice paths.
Wed, 30 Dec 2015 21:23:21 +0100https://ask.sagemath.org/question/31910/how-to-plot-lattice-paths/?answer=31918#post-id-31918