绘制此人字形图的更智能方法是什么?

绘制此人字形图的更智能方法是什么?

我正在尝试在 TikZ 中复制此图表

在此处输入图片描述

肯定有更聪明的方法来实现更多相关功能,但我是初学者。这是 MWE。

            \documentclass[tikz,border=10pt]{standalone}
            \usetikzlibrary{arrows}
            \usetikzlibrary{shapes,decorations.shapes}
            \tikzset{
            blockleft/.style= {shape=signal, draw, text width=0.80cm,
            text centered, rounded corners, minimum height=2cm,
            decoration={shape backgrounds,shape size=0.5cm,},
            signal from=west, signal to=east,}}
            \tikzset{
            blockright/.style= {shape=signal, draw, text width=0.80cm,text centered, rounded corners, minimum         height=2cm,decoration={shape backgrounds,shape size=0.5cm,},signal from=east, signal to=west,},
        }
    \begin{document}
    \begin{tikzpicture} [node distance = 2.2cm] 
        \node [rectangle,rounded corners, minimum height=2cm,minimum width=4cm,draw=red,fill=red!50] (A) {Mid market};
        \node [blockleft, right of=A,fill= brown!10] (A1) {Offer};
        \node [blockleft, right of=A1,fill= red!20] (A2) {Trading costs};
        \node [blockleft, right of=A2,fill= brown!40] (A3) {MM spread};
        \node [blockleft, right of=A3,fill= brown!60] (A4) {MM Offer};      
\node [blockright, left of=A,fill= brown!10] (A1) {bid};
        \node [blockright, left of=A1,fill= red!20] (A2) {Trading costs};
        \node [blockright, left of=A2,fill= brown!40] (A3) {MM spread};
        \node [blockright, left of=A3,fill= brown!60] (A4) {MM Bid}; 
\end{tikzpicture}

在此处输入图片描述

答案1

您可以使用chains。(如果您不想使用chains,那么您真的应该使用该positioning库。)

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{chains}
\usetikzlibrary{shapes,decorations.shapes}
\begin{document}
\begin{tikzpicture}[font=\sffamily, 
   base/.style={shape=signal, draw, text width={width("Trading")},
   inner sep=0.1ex,
    text centered, rounded corners, minimum height=2cm,
    decoration={shape backgrounds,shape size=0.5cm,}},
   blockleft/.style={base,signal from=west, signal to=east},
   blockright/.style={base,signal from=east, signal to=west,}
    ]
  \begin{scope}[node distance = 1mm,start chain=A going right,nodes={on chain}]
   \node [blockright, fill= brown!60]  {MM Offer}; 
   \node [blockright, fill= brown!40]  {MM spread};
   \node [blockright, fill= red!20] {Trading costs};
   \node [blockright, fill= brown!10,signal from=nowhere]  {Offer};
   \node [rectangle,rounded corners, minimum height=2cm,minimum width=4cm,draw=red,fill=red!50] (A) {Mid market};
   \node [blockleft, fill= brown!10,signal from=nowhere] {Bid};
   \node [blockleft, fill= red!20]  {Trading costs};
   \node [blockleft, fill= brown!40] {MM spread};
   \node [blockleft, fill= brown!60] {MM Offer};      
  \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

如果您希望更接近目标,您可能需要改变一些颜色和尺寸。

\documentclass[tikz,border=10pt]{standalone}
\definecolor{mc1}{RGB}{156,154,154}
\definecolor{mc2}{RGB}{213,99,56}   
\definecolor{mc3}{RGB}{73,72,72}    
\definecolor{mc4}{RGB}{54,54,54}    
\usetikzlibrary{chains}
\usetikzlibrary{shapes,decorations.shapes}
\begin{document}
\begin{tikzpicture}[font=\sffamily, 
   base/.style={shape=signal,text width={width("Trading")},
   inner sep=0.1ex,
    text centered, 
    decoration={shape backgrounds,shape size=0.5cm,}},
   blockleft/.style={base,signal from=west, signal to=east},
   blockright/.style={base,signal from=east, signal to=west,}
    ]
  \begin{scope}[node distance = 1mm,start chain=A going right,nodes={minimum height=2.5cm,on chain}]
   \node   {MM Offer}; 
   \node [blockright, fill= mc1]  {MM spread};
   \node [blockright, fill= mc2] {Trading costs};
   \node [blockright, fill= mc3,signal from=nowhere,text=white]  {Offer};
   \node [rectangle,minimum width=3.5cm,fill=mc4,text=white] (A) {Mid market};
   \node [blockleft, fill= mc3,signal from=nowheree,text=white] {Bid};
   \node [blockleft, fill= mc2]  {Trading costs};
   \node [blockleft, fill= mc1] {MM spread};
   \node  {MM Offer};      
  \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容