Tikzpicture 問題:特別是對於「\Vertex」系列,如何定位在節點下方或上方

Tikzpicture 問題:特別是對於「\Vertex」系列,如何定位在節點下方或上方

問題涉及 t=0、t=1 和 t=2

在圖中,我想將 t=0 移至節點下方(或上方),而不調整為\draw,\path\node程式碼。我可以在程式碼中的某處添加一些小程式碼,例如label=above{...}、或其他內容嗎?anchor=south看來我需要調整\Vertex...,但我不知道在哪裡添加任何內容來更改節點的標籤。

我現在的程式碼是:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{tkz-berge}
\usetikzlibrary{trees, fit,shapes,arrows}
\usepackage{tkz-graph}
\begin{document}
  %banks path
.\begin{tikzpicture}[scale=3] 

...\GraphInit[vstyle=Classic]   

...\tikzset{EdgeStyle/.style={->,font=\scriptsize}}=[circle,draw]   

......\Vertex[x=0,y=1.5]{t=0}   

......\Vertex[x=1,y=1.5]{t=1}   

......\Vertex[x=2,y=1.5]{t=2}   

......\Edges\[label = $1+r$\]\(t=0,t=1\)

......\Edges\[label = $1+r$\]\(t=1,t=2\)

.\end{tikzpicture}   
\end{document}

我花了 3 個多小時來建立我的圖表,使其看起來完全符合我的要求,這是我的最後一個問題。

答案1

 \documentclass[a4paper,landscape]{article}
 \usepackage[left=1cm]{geometry}
 \usepackage{amsmath}
 \usepackage{xcolor}
 \usepackage{tkz-berge}
 \usetikzlibrary{fit,shapes,arrows}
 \begin{document}
 %(tri) stock's path
 \centering
 \begin{tikzpicture}[scale=3]
    \GraphInit[vstyle=Classic]
    \SetUpVertex[Lpos=-90]
      \tikzset{VertexStyle/.style = {shape=circle, fill=black,
                           minimum size=13pt,inner sep=0pt}
         }
        \Vertex[x=0,y=1.5]{S$_0$}
        \Vertex[x=1,y=2]{uS$_0$}
        \Vertex[x=1,y=1]{d$S_0$}
        \Vertex[x=2,y=1.5]{ud$S_0$}
        \Vertex[x=2,y=2.5]{u$^2$S$_0$}
        \Vertex[x=2,y=.5]{d$^2S_0$}
        \tikzset{EdgeStyle/.style={->,font=\scriptsize},{below=15pt}}
            \Edge[label = $\widetilde{p}$](S$_0$)(uS$_0$) 
            \Edges[label = $1-\widetilde{p}$](S$_0$,d$S_0$)
            \Edges[label = $\widetilde{p}$](uS$_0$,u$^2$S$_0$)
            \Edges[label = $1-\widetilde{p}$](uS$_0$,ud$S_0$)
            \Edges[label = $1-\widetilde{p}$](d$S_0$,d$^2S_0$)
            \Edges[label = $\widetilde{p}$](d$S_0$,ud$S_0$)
 \end{tikzpicture}    
  \\
 %banks path
 \begin{tikzpicture}[scale=3]
    \GraphInit[vstyle=Classic]
    \SetUpVertex[Lpos=-90]
     \tikzset{VertexStyle/.style = {shape=circle, fill=black,
                           minimum size=13pt,inner sep=0pt}
         }
        \Vertex[x=0,y=1.5,]{t=0}
        \Vertex[x=1,y=1.5]{t=1}
        \Vertex[x=2,y=1.5]{t=2}
           \tikzset{EdgeStyle/.style={->,font=\scriptsize,above,sloped,midway}}
              \Edges[label = $1+r$](t=0,t=1)
              \Edges[label = $1+r$](t=1,t=2)

   \end{tikzpicture}
 \end{document}

在此輸入影像描述

我在這裡修改了程式碼

 \documentclass[a4paper,landscape]{article}
 \usepackage[left=1cm]{geometry}
 \usepackage{amsmath}
 \usepackage{xcolor}
 \usepackage{tkz-berge}
 \usetikzlibrary{fit,shapes,arrows}
 \begin{document}
 %(tri) stock's path
 \centering
 \begin{tikzpicture}[scale=3]
    \GraphInit[vstyle=Classic]
    \SetUpVertex[Lpos=-90]
      \tikzset{VertexStyle/.style = {shape=circle, fill=black,
                           minimum size=13pt,inner sep=0pt}
         }
        \Vertex[x=0,y=1.5]{S$_0$}
        \Vertex[x=1,y=2]{uS$_0$}
        \Vertex[x=1,y=1]{d$S_0$}
        \Vertex[x=2,y=1.5]{ud$S_0$}
        \Vertex[x=2,y=2.5]{u$^2$S$_0$}
        \Vertex[x=2,y=.5]{d$^2S_0$}

        %\tikzset{EdgeStyle/.style={->,font=\scriptsize,below=15pt}}
         \tikzset{EdgeStyle/.style={->,font=\scriptsize,above,sloped,midway}}
            \Edge[label = $\widetilde{p}$](S$_0$)(uS$_0$) 
            \Edges[label = $1-\widetilde{p}$](S$_0$,d$S_0$)
            \Edges[label = $\widetilde{p}$](uS$_0$,u$^2$S$_0$)
            \Edges[label = $1-\widetilde{p}$](uS$_0$,ud$S_0$)
            \Edges[label = $1-\widetilde{p}$](d$S_0$,d$^2S_0$)
            \Edges[label = $\widetilde{p}$](d$S_0$,ud$S_0$)
 \end{tikzpicture}    
  \\
 %banks path
 \begin{tikzpicture}[scale=3]
    \GraphInit[vstyle=Classic]
    \SetUpVertex[Lpos=-90]
     \tikzset{VertexStyle/.style = {shape=circle, fill=black,
                           minimum size=13pt,inner sep=0pt}
         }
        \Vertex[x=0,y=1.5,]{t=0}
        \Vertex[x=1,y=1.5]{t=1}
        \Vertex[x=2,y=1.5]{t=2}
           \tikzset{EdgeStyle/.style={->,font=\scriptsize,above,sloped,midway}}
              \Edges[label = $1+r$](t=0,t=1)
              \Edges[label = $1+r$](t=1,t=2)

   \end{tikzpicture}
 \end{document}

在此輸入影像描述

相關內容