如何在 tikz 中繪製地平線圖?

如何在 tikz 中繪製地平線圖?

所以地平線 圖表看起來像這樣: 在此輸入影像描述

允許簡單地表示可以單獨檢查的函數圖頁面,同時顯示大圖和函數相關性。此外,地平線圖表可以輕鬆以黑白格式列印。

簡而言之,此類圖表的想法是,對於每一行,i您都會得到一個Y_i=F_i(X)並將其繪製出來,這樣對於每一行,如果Y_i > RowHeight我們得到一個覆蓋層並且YY_i = YY_i - RowHeight;如果YY_i > RowHeight我們得到下一個覆蓋層等。從這裡:

在此輸入影像描述

變成

在此輸入影像描述

那麼如何使用 tikz 繪製靜態 Horizo​​n Chart 呢?

答案1

我可能誤解了這個問題,但從我的閱讀方式來看,你只需要剪輯和小的相對位移。

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\newsavebox\DuckBox
\sbox\DuckBox{\begin{tikzpicture}[trig format=rad]
 \fill[blue!20] plot[variable=\x,domain=0:10,samples=31,smooth] 
  (\x,{1.5+(1+0.5*rnd)*sin(\x)*sin(\x)}) |- (0,0);
 \fill[blue!40] plot[variable=\x,domain=0:10,samples=61,smooth] 
  (\x,{1+(1+0.5*rnd)*sin(\x)*sin(\x)*sin(2*\x)*sin(2*\x)}) |- (0,0);
 \fill[blue!60] plot[variable=\x,domain=0:10,samples=61,smooth] 
  (\x,{0.5+(1+0.5*rnd)*sin(\x)*sin(\x)*sin(2*\x)*sin(2*\x)}) |- (0,0);
\end{tikzpicture}}
\begin{document}
\begin{tikzpicture}
\foreach \X [count=\Y] in {pft,blub,bla,quack,meow}
 {\begin{scope}
  \clip (-5,\Y*0.52) rectangle (5,0.5+\Y*0.52);
  \node[anchor=south] at (0,0.2+\Y*0.15) {\usebox\DuckBox};
  \node[anchor=south west,font=\sffamily] at (-5,\Y*0.52) {\X};
 \end{scope}}
\end{tikzpicture}
\end{document}

在此輸入影像描述

對於新版本的問題,答案在性質上是相同的。

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\newsavebox\DuckBox
\sbox\DuckBox{\begin{tikzpicture}[trig format=rad]
 \path[save path=\pathA] plot[variable=\x,domain=0:10,samples=151] 
  (\x,{-(1.2+0.5*rnd)*sin(1.15*\x-1)+0.5*sin(2*\x)+\x/3}) |- (0,0);
 \foreach [count=\Y starting from 0] \X in 
    {blue!20,orange!20,orange!40,orange!60,orange!80}
  {\begin{scope}
    \clip (0,1.5*\Y-1.5) rectangle (10,1.5*\Y);
    \fill[\X,use path=\pathA];
   \end{scope}}
\end{tikzpicture}}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,outer sep=0pt,inner sep=0pt] 
  at (0,4) {\usebox\DuckBox};
\clip (0,0) rectangle (10,1.5);
\node[anchor=south west,outer sep=0pt,inner sep=0pt,yscale=-1] 
  at (0,1.5) {\usebox\DuckBox};
\foreach \Y in {1,...,4}
 {\node[anchor=south west,outer sep=0pt,inner sep=0pt] 
  at (0,-1.5*\Y) {\usebox\DuckBox};
 }
\end{tikzpicture}
\end{document}

在此輸入影像描述

相關內容