# Graph Basic linear inequality

I am trying to graph a basic linear inequality (y < -2x + 5).

I started something. I could figure out how to graph y = -2x + 5.

In short what I'm trying to get:

What I currently have:

The code for what I have:

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}

\begin{tikzpicture}[scale=1]
\begin{axis}[x=1cm,y=1cm,
axis lines = middle,
xlabel = {$x$},
ylabel = {$y$},
xmin=-5, xmax=5,
ymin=-5, ymax=5,small,
grid]

domain = -5:5,
samples = 1000,blue,very thick] {-2*x+5}
node [pos=.65, right] {};

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


Any help would be appreciated!

Like this:

Code:

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}

\begin{tikzpicture}[scale=1]
\begin{axis}[x=1cm,y=1cm,
axis lines = middle,
xlabel = {$x$},
ylabel = {$y$},
xmin=-5, xmax=5,
ymin=-5, ymax=7,small, % changed
grid]

domain = -5:5,
samples = 1000,blue,very thick] {-2*x+5}
node [pos=.65, right] {};
\fill[red!30,opacity=.5] (-5,-5) rectangle (-1,7); % added
\end{axis}
\end{tikzpicture}
\end{document}

• Super helpful! I try messing around to learn how else I could shade based on what you had above (I think I got the hang of the shading. Like you did a rectangle and a triangle). Very very helpful! Thanks so much Commented Jun 5, 2023 at 3:54
• You are wellcome! Commented Jun 5, 2023 at 8:39