我想要绘制三张如下的图表:
有没有简单的方法来绘制这些虚线区域?
这是我目前所拥有的:
来自以下代码:
\documentclass[11pt]{article}
\usepackage{tikz}
\begin{document}
Damping:\\
\begin{tikzpicture}[scale=0.6]
\draw[->] (-4.5,0) -- (1.5,0);
\draw[->] (0,-4.5) -- (0,4.5);
\foreach \x in {-4,-3,-2,-1,0,1}
\draw (\x cm,1.5pt) -- (\x cm,-1.5pt);
\foreach \y in {-4,-3,-2,-1,0,1,2,3,4}
\draw (1.5pt,\y cm) -- (-1.5pt,\y cm);
\draw[thick,red] (0,0)--(-4,4);
\draw[thick,red] (0,0)--(-4,-4);
\end{tikzpicture}
Settling Time:\\
\begin{tikzpicture}[scale=0.6]
\draw[->] (-4.5,0) -- (1.5,0);
\draw[->] (0,-4.5) -- (0,4.5);
\foreach \x in {-4,-3,-2,-1,0,1}
\draw (\x cm,1.5pt) -- (\x cm,-1.5pt);
\foreach \y in {-4,-3,-2,-1,0,1,2,3,4}
\draw (1.5pt,\y cm) -- (-1.5pt,\y cm);
\draw[thick,blue] (-1,-4)--(-1,4);
\end{tikzpicture}
Frequency:\\
\begin{tikzpicture}[scale=0.6]
\draw[->] (-4.5,0) -- (1.5,0);
\draw[->] (0,-4.5) -- (0,4.5);
\foreach \x in {-4,-3,-2,-1,0,1}
\draw (\x cm,1.5pt) -- (\x cm,-1.5pt);
\foreach \y in {-4,-3,-2,-1,0,1,2,3,4}
\draw (1.5pt,\y cm) -- (-1.5pt,\y cm);
\draw[thick,orange] (-4,4)--(1,4);
\draw[thick,orange] (-4,-4)--(1,-4);
\end{tikzpicture}
\end{document}
答案1
TikZ 为您提供了一个名为模式的库。要使用它,您需要\usetikzlibrary{patterns}
在序言中说明。
对于第一种情况,你可以这样做
\begin{tikzpicture}[scale=0.6]
\draw[->] (-4.5,0) -- (1.5,0);
\draw[->] (0,-4.5) -- (0,4.5);
\foreach \x in {-4,-3,-2,-1,0,1}
\draw (\x cm,1.5pt) -- (\x cm,-1.5pt);
\foreach \y in {-4,-3,-2,-1,0,1,2,3,4}
\draw (1.5pt,\y cm) -- (-1.5pt,\y cm);
\draw[thick,red,pattern=north east lines,pattern color=red] (-4,-4) -- (0,0)--(-4,4);
\end{tikzpicture}
因此,关键是要有一个大致确定的表面。对于案例 #2 和 #3,\fill[pattern=north west lines] (0,1) rectangle (2,2);
使用调整后的坐标即可。
当然,如果你参考手册的话,还有更多定义的模式(http://www.ctan.org/pkg/pgf)。