我正在尝试使用 Tikz 从有关市场结构的演示文稿中重新创建图像:
我很难指定每个节点的绝对位置。对于这样的情况,分配块位置的最佳方法是什么?
以下是我目前所掌握的信息:
\tikzstyle{trade} = [rectangle, minimum height=0.5cm, text
centered, color=white, draw=black, fill=red]
\tikzstyle{order} = [rectangle, minimum height=0.5cm, text
centered, color=white, draw=black, fill=blue]
\begin{tikzpicture}[node distance=1cm]
\node (trade) at (0, 0) [trade, minimum width=6cm] {Marketable Order};
\node (o1) [order, below of=trade, minimum width=0.5cm, xshift=-2.75cm, node
distance=2cm] {1};
\node (o2) [order, right of=o1, minimum width=1cm] {2};
\node (o3) [order, right of=o2, minimum width=3cm, xshift=1cm] {3};
\node (o4) [order, right of=o3, minimum width=1cm, xshift=2cm] {4};
\draw[->] (trade.west) -- (o1.west);
\draw[->] (o1.north) to [out=180] (o2.north);
\end{tikzpicture}
答案1
我今天沒做任何工作!
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{positioning}
\tikzset{
blueblock/.style = {draw,rectangle,fill = blue,text=white,align = center,font=\sffamily},
every node/.style = {font=\sffamily}
}
\begin{document}
\begin{tikzpicture}
%% horizontal nodes
\node[anchor=east] at (-0.5,0) {Best bid price};
\node[coordinate] (0) at (-0.5,0) {};
\node[blueblock,minimum width = 1cm,right=.5cm of 0] (1) {1};
\node[blueblock,minimum width = .5cm,right=.5cm of 1] (2) {2};
\node[blueblock,minimum width = 1.5cm,right=.5cm of 2] (3) {3};
\node[blueblock,minimum width = 1.2cm,right=.5cm of 3] (4) {4};
\node[blueblock,minimum width = .3cm,right=.5cm of 4] (5) {5};
\node[blueblock,minimum width = .6cm,right=.5cm of 5] (6) {6};
\node[blueblock,minimum width = 2.5cm,right=.5cm of 6] (7) {7};
\node[coordinate,right=.5cm of 7] (8) {};
%
\node[draw,fill=red,rectangle,minimum width = 4cm,label=above:Incoming market sell order,anchor=west] (red) at (0,6) {\vphantom{1}};
\node[align=center,text width = 4cm,anchor=south] at (2.5,4) {Earliest limit order filled completely first};
\node[align=center,text width = 5.5cm] at (3,2) {Remaining quantity \\ in time order};
\node[align=center,text width = 5.5cm,above = 3cm of 6] (rest) {Resting limit buy orders \\ of different sizes};
%
\draw[-stealth] ([yshift=-1cm]2.east) -- ([yshift=-1cm]7.west)node[below,pos=0.5] {Time of order submission};
%lines and arrows
\draw[-stealth,shorten >=2pt] (red.south) -| (1.north);
\draw[-stealth,shorten >=2pt,shorten <=2pt] (rest.south) -- (4.45);
\draw[-stealth,shorten >=2pt,shorten <=2pt] (rest.south) -- (5.65);
\draw[-stealth,shorten >=2pt,shorten <=2pt] (rest.south) -- (6);
\foreach \x [remember=\x as \lastx (initially 0)] in {1,...,8}{
\path[draw] (\lastx)--(\x);
}
\foreach \x [remember=\x as \lastx (initially 1)] in {2,...,4}{
\draw (\lastx.65) edge [bend left,-stealth,shorten >=2pt,shorten <=2pt](\x.115);
}
\end{tikzpicture}
\end{document}