1

I'm only aware of how to shade area between two curves, Simply by specifying a path for each curve with the parameter : Name path=A, etc. so far it worked by specifying 2 paths and then using command

\addplot [gray!30] fill between [of = A and B, soft clip={domain=1:3}];

I Wish to Shade Area bounded between three Lines, so on attempting to specify a third path C the command gives me an error, the said region in question looks like this:

enter image description here

Qrrbrbirlbel
  • 119,821
Cristofer
  • 11
  • 1
  • https://tex.stackexchange.com/questions/516723/fill-space-between-three-draw-lines-with-arbitrary-intersection-points and https://tex.stackexchange.com/questions/398630/how-to-shade-the-intersection-of-3-lines – js bibra Sep 01 '23 at 12:33
  • If You want to follow the fill between method, make this in two steps;
    1. from 1 to 2 for lines A and B;
    2. grom 2 to 3 for lines C and B.
    – Raffaele Santoro Sep 01 '23 at 14:00

1 Answers1

1

Short answer. After plotting the three line You know the intersection points A(1,2), B(2,0) and C(4,3). So add the line:

\fill[gray] (1,2)--(2,0)--(4,3)--cycle;

(Almost) full answer.

\documentclass[a4paper]{article}
\usepackage{tikz}

\begin{document}

\begin{center} \begin{tikzpicture}[font=\sffamily\small] % \draw[gray!20,step=0.5cm] (-6.5,-2) grid (6.5,6.5); % \draw[->,thick] (-6.6,0) -- (6.6,0) node[anchor=west]{$x$}; \draw[->,thick] (0,-2) -- (0,6.6) node[anchor=south]{$y$}; % \foreach \x in {-6,-5,...,6} \draw [thick](\x cm,-2pt) -- (\x cm,2pt); \foreach \y in {-2,-1,...,6} \draw thick -- (2pt,\y); % \foreach \x in {-6,-5,...,6} \draw (\x cm, 0 cm) node[anchor=north]{\x}; \foreach \y in {-2,-1,...,6} \draw (0 cm, \y cm) node[anchor=east]{\y};

    \fill[gray] (1,2)--(2,0)--(4,3)--cycle;
    \clip (-6.5,-2) rectangle (6.5,6.5);
    \draw[cyan,line width=2pt] plot[domain=-6.5:6.5] (\x,{\x/3+5/3});
    \draw[cyan,line width=2pt] plot[domain=-6.5:6.5] (\x,{-2*\x+4});
    \draw[cyan,line width=2pt] plot[domain=-6.5:6.5] (\x,{3*\x/2-3});
\end{tikzpicture}

\end{center}

\end{document}

Output:

enter image description here