\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}
\draw plot [hobby] coordinates {(0,4) (1,3.2) (2,1.5) (2.5,1.2) (3,1) (4,0.8)};
\end{tikzpicture}
\begin{tikzpicture}
\draw[black, thick] (-1,1) -- (1,-1);
\draw[black, thick] (-1,-1) -- (1,1);
\filldraw[black] (0,0) circle (2pt) ;
\draw[black, thick] (0,0) -- (0,-1.5);
\draw[black, thick] (0,-1.5) -- (0.5,-1);
\draw[black, thick] (0,-1.5) -- (-0.5,-2);
\filldraw[color=red!60, fill=red!5, very thick](-1,1) circle (.3);
\filldraw[color=red!60, fill=white, very thick](-1,-1) circle (.3);
\filldraw[color=red!60, fill=red!5, very thick](1,-1) circle (.3);
\filldraw[color=red!60, fill=red!5, very thick](1,1) circle (.3);
\draw (-.5,-2) .. controls (0.1,-2.8) and (.3,-2) .. (.5,-1);
\end{tikzpicture}
\end{document}
我已經做到了這一點,但不知道如何將其放在路徑上。
答案1
我建議使用pic
,它就像一個tikzpicture
可以在路徑上使用的迷你。在下面的程式碼中,我獲取了您的無人機代碼並將其轉換為pic
.程式碼的來源決定了pic
放置的位置,因此我使用移動了放置位置yshift
(並且還縮放了它)。然後您可以將其放置在路徑上,就像放置任何節點一樣。
為了好玩,我使用隨機創建了一條河流decorations.pathmorphing
。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, decorations.pathmorphing}
\tikzset{drone/.pic={
\draw[black, thick] (-1,1) -- (1,-1);
\draw[black, thick] (-1,-1) -- (1,1);
\filldraw[black] (0,0) circle (2pt) ;
\draw[black, thick] (0,0) -- (0,-1.5);
\draw[black, thick] (0,-1.5) -- (0.5,-1);
\draw[black, thick] (0,-1.5) -- (-0.5,-2);
\filldraw[color=red!60, fill=red!5, very thick](-1,1) circle (.3);
\filldraw[color=red!60, fill=white, very thick](-1,-1) circle (.3);
\filldraw[color=red!60, fill=red!5, very thick](1,-1) circle (.3);
\filldraw[color=red!60, fill=red!5, very thick](1,1) circle (.3);
\draw (-.5,-2) .. controls (0.1,-2.8) and (.3,-2) .. (.5,-1);
}
}
\begin{document}
\begin{tikzpicture}[every pic/.style={yshift=1cm, scale=.5, transform shape}]
\pgfmathsetseed{1415}
\draw[decorate, decoration={random steps, segment length=3mm, amplitude=1pt}, line width=8mm, cyan!60!white](-.5,-.4)--(9,-.4);
\draw[<->, thick](0,1.5)node[left]{$z$}|-(1.5,0)node[below]{$x$};
\draw(0,4)to[out=-20, in=180]pic[pos=0]{drone}pic[pos=1]{drone}(5,0)pic[xshift=3cm]{drone};
\draw[<->, thick, red](0,-1)--node[below]{flying}(5,-1);
\draw[<->, thick, red](5,-1)--node[below]{sailing}(9,-1);
\end{tikzpicture}
\end{document}