如何在 PSTricks 上绘制 Dyck 路径?

如何在 PSTricks 上绘制 Dyck 路径?

我想知道如何使用 PSTricks 而不是 Tikz 轻松绘制类似于下面的 Dyck 路径。有什么想法吗?

谢谢你!

\documentclass[border=2mm]{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=0.8]
(8,0) rectangle +(5,5);
\draw[help lines] (8,0) grid +(5,5);
\draw[dashed] (8,0) -- +(5,5);
\coordinate (prev) at (8,0);
\draw [color=blue, line width=2] (8,0)--(9,0)--(10,0)--(10,1)--(13,1)--(13,3)--(13,5);
\draw [color=red, line width=1] (8,0)--(9,0)--(10,0)--(10,1)--(10,2)--(13,2)--(13,3)--(13,5);

\draw (10,1) node [scale=0.5, circle, draw,fill=blue]{};
\draw (13,2) node [scale=0.5, circle, draw,fill=red]{};
 \end{tikzpicture}
}
\end{document}

答案1

\documentclass[pstricks,border=2mm]{standalone}
\usepackage{pstricks}
\begin{document}

\psset{unit=0.8}
\begin{pspicture}(8,0)(13,5)
\psgrid[gridlabels=0pt,subgriddiv=1,gridcolor=black!30](8,0)(13,5)
\psline[linestyle=dashed](8,0)(13,5)
\psline[linecolor=blue,linewidth=2pt](8,0)(9,0)(10,0)(10,1)(13,1)(13,3)(13,5)
\psline[linecolor=red,linewidth=1pt](8,0)(9,0)(10,0)(10,1)(10,2)(13,2)(13,3)(13,5)
\psdot[linecolor=blue,dotscale=1.5](10,1)
\psdot[linecolor=red,dotscale=1.5](13,2)
\end{pspicture}

\end{document}

在此处输入图片描述

相关内容