无限填充区域

无限填充区域

我需要绘制一个具有无限填充区域的图形作为附件图形。谢谢!在此处输入图片描述

答案1

这可以通过fillbetween以下库实现pgfplots。请参阅手册以了解如何粘贴标签和去除勾号等。您也可以在此网站上搜索示例。

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,
    axis equal,
    grid=both,
    xlabel=A,ylabel=B,
    no marks,
    domain=-10:10,
    xmax=5,xmin=-5,ymax=5,ymin=-5,samples=3]% lines don't need too many samples
\addplot+[name path=o,draw=none] {0};
\addplot+[name path=a] {-1*x};
\addplot+[name path=b] {1/6*x};
\addplot+[name path=c] {1/2*x};
\addplot+[name path=d] {3*x};

\addplot[pattern=north east lines,pattern color=blue] fill between[of=o and b] ;
\addplot[pattern=north west lines,pattern color=red] fill between[of=b and c] ;
\addplot[pattern=vertical lines,pattern color=green] fill between[of=c and d] ;
\addplot[pattern=horizontal lines,pattern color=orange] fill between[reverse=false,of=a and d] ;
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

一旦您感到舒适,您就可以用 for 循环产生相同的效果。

相关内容