在图表中,我想将 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}