4

Consider an angle (on a plane) with the vertex O, the initial side (ray1) and the terminal side (ray2). Assume the measure of this angle is less than 360 degrees. (There are two such angles.) Consider another ray (ray3) with the same vertex O that can rotate between ray1 and ray2 with center O. I want to shade the region swept out by ray3 using a hatch pattern. There are two possibilities.

(1) The rotation is counterclockwise
(2) The rotation is clockwise

After reading several questions and answers (at tex.sx on pgfplots), I have a reasonably acceptable answer to possibility (1). (See the code and the figure below.) (Please feel free to improve the answer to the first possibility.)

\documentclass[11pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\begin{document}

\pgfdeclarepatternformonly[\LineSpace]{my north west lines}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{\LineSpace}{\LineSpace}}{\pgfqpoint{\LineSpace}{\LineSpace}}%
{
    \pgfsetlinewidth{0.4pt}
    \pgfpathmoveto{\pgfqpoint{0pt}{\LineSpace}}
    \pgfpathlineto{\pgfqpoint{\LineSpace + 0.1pt}{-0.1pt}}
    \pgfusepath{stroke}
}

\newdimen\LineSpace
\tikzset{
    line space/.code={\LineSpace=#1},
    line space=3pt
}

\begin{tikzpicture}

\begin{axis}[hide axis, xmin=-1, ymin=-1, xmax=10,ymax=10,
disabledatascaling]

\addplot[domain=0:10,samples=300]
{0};
\addplot[domain=0:6,samples=300]
{x};

\addplot[red,domain=0:7,samples=300]
{x/2};

\addplot[domain=0:9,samples=300,name path=A]
{0};
\addplot[domain=0:4,samples=300,name path=B]
{x};
\addplot[line space=5pt, pattern= my north west lines] fill between[of=A and B];
\draw [red, line width=2pt, ->] (axis cs:2,0) arc [radius=2, start angle=0,end angle=45];
\end{axis}
\end{tikzpicture}
\end{document} 

enter image description here

Is it possible to get an answer to the second possibility?

enter image description here

Note: I want to shade the region within the angle so that the boundary of the shaded region has some sort of a blurry shape. (Definitely not a circular shape.) I failed miserably conveying this idea through my posted image. However, I might be able to get something reasonable by playing with the clipping idea.

enter image description here

4

Another option is use of clip within scope environment, based on the existing code.

enter image description here

Code:

\documentclass[border=10pt]{standalone}%[11pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{fillbetween}
\usepackage{xcolor}
\usetikzlibrary{patterns}
\begin{document}

\pgfdeclarepatternformonly[\LineSpace]{my north west lines}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{\LineSpace}{\LineSpace}}{\pgfqpoint{\LineSpace}{\LineSpace}}%
{
    \pgfsetlinewidth{0.4pt}
    \pgfpathmoveto{\pgfqpoint{0pt}{\LineSpace}}
    \pgfpathlineto{\pgfqpoint{\LineSpace + 0.1pt}{-0.1pt}}
    \pgfusepath{stroke}
}

\newdimen\LineSpace
\tikzset{
    line space/.code={\LineSpace=#1},
    line space=3pt
}

\begin{tikzpicture}

\begin{axis}[hide axis, xmin=-10, ymin=-10, xmax=10,ymax=10,
disabledatascaling]

\addplot[domain=0:10,samples=300]
{0};
\addplot[domain=0:6,samples=300]
{x};
\addplot[red,domain=0:7,samples=300]
{x/2};

\addplot[domain=0:9,samples=300,name path=A]
{0};
\addplot[domain=0:4,samples=300,name path=B]
{x};
\begin{scope}
\clip[] (0:0)--(0:4) arc (0:-315:4);
\fill [line space=3pt,pattern= north east lines,pattern color=blue] (0,0) circle (2cm);
\end{scope}
\addplot[line space=5pt, pattern= my north west lines] fill between[of=A and B];
\draw [red, line width=2pt, ->] (axis cs:2,0) arc [radius=2, start angle=0,end angle=45];
\draw [blue, line width=1pt, ->] (axis cs:1,0) arc [radius=1, start angle=0,end angle=-315];
\end{axis}
\end{tikzpicture}
\end{document} 
  • I do not know why people are up-voting the other answer. Your answer is the closest to what I want. Let me see if I can adopt your answer and then accept your answer. – Sony Aug 26 '14 at 20:00
6
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{patterns,angles}
\begin{document}

\tikz \draw (2,0) coordinate (A) -- (0,0) coordinate (B)
-- (-1,-1) coordinate (C)
pic [draw,->,red,pattern=north west lines] {angle = A--B--C}
pic [draw,<-,blue,pattern=north east lines,thick,angle radius=1cm] {angle = C--B--A};

\end{document}

enter image description here

Adopting to the given code:

\documentclass[11pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns,angles}
\begin{document}

\pgfdeclarepatternformonly[\LineSpace]{my north west lines}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{\LineSpace}{\LineSpace}}{\pgfqpoint{\LineSpace}{\LineSpace}}%
{
    \pgfsetlinewidth{0.4pt}
    \pgfpathmoveto{\pgfqpoint{0pt}{\LineSpace}}
    \pgfpathlineto{\pgfqpoint{\LineSpace + 0.1pt}{-0.1pt}}
    \pgfusepath{stroke}
}

\newdimen\LineSpace
\tikzset{
    line space/.code={\LineSpace=#1},
    line space=3pt
}

\begin{tikzpicture}

\begin{axis}[hide axis, xmin=-10, ymin=-10, xmax=10,ymax=10,
disabledatascaling]

\addplot[domain=0:10,samples=300]
{0};
\addplot[domain=0:6,samples=300]
{x};

\addplot[red,domain=0:7,samples=300]
{x/2};

\addplot[domain=0:9,samples=300,name path=A]
{0}coordinate (A);                  %% define a coordinate
\addplot[domain=0:4,samples=300,name path=B]
{x}coordinate (B);                  %% define another coordinate

\addplot[line space=5pt, pattern= my north west lines] fill between[of=A and B];
\draw [red, line width=2pt, ->] (axis cs:2,0) arc [radius=2, start angle=0,end angle=45];

\coordinate (O) at (axis cs:0,0);                    %% define another coordinate
\draw pic [draw,<-,blue,pattern=north east lines,thick,angle radius=1cm] {angle = B--O--A}; %% draw the fill

\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.