1

How can I redefine the less than inequality in the below MWE so that it resembles the one shown by the screenshot?

enter image description here

Here is the code used.

\begin{tikzpicture}[scale=0.7]
    % Draw the grid
    \tikzset{help lines/.style={color=blue!50}}
    \draw[thick,step=1cm,help lines] (0,0) grid (20,13);
    \draw[thin,step=2mm,help lines] (0,0) grid (20,13);
    \begin{axis}[thick,
        axis x line=center,  axis y line=center,
        axis on top,
        width=16cm,           height=16cm,
        x axis line style={latex-latex},
        y axis line style={latex-latex},
        x=1cm,
        y=1cm,
        xtick={0,1,2,...,18},
        ytick={0,1,2,...,12},
        ticklabel style={font={{\normalsize }}, fill=white,
            inner sep=1pt},
        xmin=-2,   xmax=18.5,
        ymin=-1,   ymax=12.5
        ]
        %line one
        \addplot [IneqStyleGtr,
        domain=-1:18,line width=1.5pt,
        ] {-4*x+24};
        %line two
        \addplot [IneqStyleGtr,line width=1.5pt,
        domain=-1:15,
        ] {-1.3333333333*x+10.666666666667};
        %line three - y axis
        \addplot [IneqStyleLess,
        thick,black!80!white,domain=-1:18,line width=1.5pt] coordinates {(0,0) (18,0)};
            \addplot [IneqStyleGtr,
        thick,black!80!white,domain=-1:18,line width=1.5pt] coordinates {(0,0) (0,12)};
        %line 4 x axis
        \addplot [IneqStyleGtr,
        thick,black!80!white,domain=-1:16,line width=1.5pt] {-0.5*x+9};
        
        
        \node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:18,0.2) {$x$-axis};
        \node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:0.6,12) {$y$};
        %line one
        \node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:11,0.2) {$y=0$};
        
        \node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:4.2,11.3) {$4x+y=24$};
        %line two
        \node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:13.5,3) {$x+2y=18$};
        %line three
        \node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:8.5,1) {$4x+3y=32$};
        %line four
        \node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:-1,6) {$x=0$};
        
        %ORIGIN
        \node[fill=white,rounded corners=2pt,inner sep=1pt] at (axis cs:-0.2,-0.2) {$0$};
    \end{axis}
\end{tikzpicture}
2
  • 1
    Welcome to TeX.SE! it will be fine if you would extend your code fragment to complete small document. We like to see your command definitions and packages needed for compile your code.
    – Zarko
    Jul 2, 2022 at 10:09
  • Any news? Does received answer solve your problem?
    – Zarko
    Jul 8, 2022 at 13:58

1 Answer 1

4
  • Please always provide MWE (Minimal Working Example), a complete small, compilable document, which reproduce your problem and show where you stuck in your effort to solve it.
  • Your question is not entirely clear, what is your problem. Your code fragment contain undefined command, also is not close to showed image, so I guessing what you after.
  • Something like this?

enter image description here

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween} 
\usetikzlibrary{intersections,
                patterns}


\begin{document}
    \begin{tikzpicture}[scale=0.5,
lbl/.style = {#1, near end, font=\small, sloped} % #1: position
                        ]
   \begin{axis}[
    axis lines=center, semithick,
    x=10mm, y=10mm,
    xlabel=$x$,
    ylabel=$y$,
    label style = {font=\Large},
grid=both, minor tick num=9,
major grid style = {blue!30},    
minor grid style = {very thin,  blue!15},    
    ticklabel style={rounded corners, font=\scriptsize, fill=white, inner sep=1pt},
        xmin=-10,  xmax=10,  xtick={-10,-9,...,10},
        ymin=-10,  ymax=10,  ytick={-10,-9,...,10},
%
every axis plot post/.append style={thick, color=black},
    domain = -10:10, no marks
                ]
        %line one
\addplot[name path=A]   {x} node[lbl=above] {$y>x$}
                            node[lbl=below] {$y<x$};
\path   [name path=B] (-10,10) -- (-10,10);

\addplot[pattern=north west lines, 
         distance=2.82mm,
         pattern color=orange!50]
         fill between[of=A and B];
\end{axis}
    \end{tikzpicture}
\end{document}
5
  • Yes, thank you for this Jul 2, 2022 at 14:04
  • @ElijahOjiambo, you can (now) upvote answer or even accept it (by clicking on up-triangle amd checkmark at top left side of answer. As I see, so far you not accept any of received answer. Why? Does no one solve your problem.
    – Zarko
    Jul 2, 2022 at 17:25
  • @ElijahOjiambo Please accept Zarko's answer if this works for you. It also solves my unasked question perfectly, but I cannot ask the duplicate question.
    – MattD626
    Jul 3, 2022 at 5:22
  • Kindly help on how I can accept his answer, I'm a beginner on this matter Jul 8, 2022 at 15:44
  • @ElijahOjiambo, click on check mark at top left side of answer. For upvote you find there up-triangle. By clicking on it you express your thankfulness for help ;-)
    – Zarko
    Jul 8, 2022 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .