![用汽车和自行车等元素绘制桥梁](https://linux22.com/image/462723/%E7%94%A8%E6%B1%BD%E8%BD%A6%E5%92%8C%E8%87%AA%E8%A1%8C%E8%BD%A6%E7%AD%89%E5%85%83%E7%B4%A0%E7%BB%98%E5%88%B6%E6%A1%A5%E6%A2%81.png)
只是为了好玩。可以用 tikz 画出下面的内容吗(包括一辆小汽车和一辆自行车)?
这是我实现它的一次尝试。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{figure}[ht!]
\centering
\begin{adjustbox}{width=\columnwidth,center}
\begin{tikzpicture}
\begin{axis} [
minor tick num=1,
%grid=both,
axis lines=middle,
inner axis line style={=>},
xlabel={\small $x$},,
ylabel={\small $f(x)$},
ylabel style={xshift=0cm, yshift=0.22cm},
x=0.25cm,
y=0.25cm,
ytick={-40,-38,...,40},
xtick={-30,-28,...,30},
%xticklabels = {, , , -2, ,2 , ,,},
%yticklabels = {, ,-2 ,, 2, , ,,},
ymin=-40.33,
ymax=40.33,
xmin=-40.33,
xmax=40.33,
]
\addplot [color=red, domain=-20:20, samples=100, thick] {0.03125*x^2};
\addplot [color=red, domain=-40:-20, samples=100, thick] {0.03125*(x+40)^2};
\addplot [color=red, domain=20:40, samples=100, thick] {0.03125*(x-40)^2};
\addplot +[mark=none] coordinates {(15, 0) (15,225/32)};
\addplot +[mark=none] coordinates {(10, 0) (10,25/8)};
\addplot +[mark=none] coordinates {(5, 0) (5,25/32)};
\addplot +[mark=none] coordinates {(-15, 0) (-15,225/32)};
\addplot +[mark=none] coordinates {(-10, 0) (-10,25/8)};
\addplot +[mark=none] coordinates {(-5, 0) (-5,25/32)};
\addplot +[mark=none] coordinates {(20,-10) (20,20)};
\addplot +[mark=none] coordinates {(-20,-10) (-20,20)};
\addplot +[mark=none] coordinates {(-20,12.5) (20,12.5)};
\end{axis}
\end{tikzpicture}
\end{adjustbox}
\end{figure}
\end{document}
答案1
第一种方法,fontawesome5
(这是作弊吗?):
\documentclass[tikz,border=2mm]{standalone}
\usepackage{fontawesome5}
\tikzset{vehicle/.style={anchor=base,scale=0.5,teal}}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
\node[vehicle] at (1,\pgflinewidth) {\faBiking};
\node[vehicle] at (5,\pgflinewidth) {\faCarSide};
\node[vehicle] at (4,\pgflinewidth) {\faAmbulance};
\draw[thick] (0,0) -- (6,0);
\foreach\i in {1.5,4.5}
{
\begin{scope}[shift={(\i,0)}]
\draw[thick] (0,-1) -- (0,3);
\foreach\j in {-1,1}
{
\draw[blue] (1.5*\j,0) parabola (0,2);
\foreach\k in {1,2,3}
\draw[blue!60] (1.5*\j-0.375*\j*\k,0) --++ (0,0.125*\k*\k);
}
\end{scope}
}
\end{tikzpicture}
\end{document}