我携带了以下代码,
\begin{center}
\begin{tikzpicture}[scale=.9]
\draw[<->] (-1,0) -- (2*pi,0) node[below] {$x$};
\draw[thick] (4,0)--(4,1/2);
\draw[thick] (4,0)--(4,-1/2);
\draw[thick] (1.3,1/2)--(1.3,-1/2);
\draw[thick] (2.6,1/2)--(2.6,-1/2);
\draw (0,-1/6) node[left] {};
\draw[<->] (0,-1) -- (0, 3) node[left] {$y$};
\draw[-,domain = 0:4,thick]
plot (\x,{1/2}) node[right] {};
\draw[-,domain = 0:4,thick]
plot (\x,{-1/2}) node[right] {};
\end{tikzpicture}
\end{center}
我需要填写表格并贴上标签。有人可以帮我做这件事,谢谢。
答案1
你可以把标签放在\node
您可以像在轴中一样钾Z 库patterns
可能会有所帮助。最后,您可以使用库绘制支架decorations.pathreplacing
。
我更改了您原来的比例,否则我认为文本会非常大。您可以根据需要恢复该比例或更改文本大小。
代码:
\documentclass[border=2mm,tikz]{standalone}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.pathreplacing} % for the overbrace
\tikzset%
{% this sytle provides the overbrace (form decorations.pathreplacing)
mybrace/.style={decorate,decoration={brace,raise=2mm,amplitude=3pt}},
}
\begin{document}
\begin{tikzpicture}[scale=1.5,line join=round,line cap=round]
% axes
\draw[<->] (-1,0) -- (2*pi,0) node[below] {$x$};
\draw[<->] (0,-1) -- (0, 3) node[left] {$y$};
% big rectangle (and nodes, labels)
\draw[thick] (0,-1/2) node [below left] {\strut$x=0$} -- (4,-1/2) node [below] {\strut$x=\ell$} |- (0,1/2);
% filled rectangle (and another node)
\draw[thick,pattern=north east lines] (1.3,-1/2) node [below] {\strut$x$} rectangle (2.6,1/2);
% one more node
\node at (2.6,-1/2) [below] {$x+\Delta x$};
% overbrace
\draw[mybrace] (1.3,1/2) -- (2.6,1/2) node[midway,yshift=5mm] {\strut $\Delta x$};
\end{tikzpicture}
\end{document}