plotting a linear programming problem












4















I am a beginner in latex , but I am learning as I go, I want to plot the following linear programing problem:



(plot : to make a graphic)



f(x,y) = 2x - 3y -> max

x + y <= 12

x,y >=0


here is what I have so far, but I can`t find any good answers on how to draw in latex:



documentclass[12pt]{article}
usepackage{amsmath}
usepackage{graphicx}
usepackage{pgfplots}
usepackage{tikz}
usepackage{hyperref}
usepackage[latin1]{inputenc}


title{Linear Programming}
date{12/27/18}

begin{document}
maketitle

bigbreak
a) begin{cases} f(x,y) = 2x - 3y rightarrow max \x + y leq 12 \ x , y geq 0 end{cases}

bigbreak
bigbreak

begin{tikzpicture}
begin{axis}
[
xmin=-20,xmax=20,
ymin=-20,ymax=20,
grid=both,
grid style={line width=.1pt, draw=darkgray!10},
major grid style={line width=.2pt,draw=darkgray!50},
axis lines=middle,
minor tick num=4,
enlargelimits={abs=0.5},
axis line style={latex-latex},
samples=100,
domain = -20:20,
]
addplot[red] {x + y <= 12};

end{axis}
end{tikzpicture}


end{document}


Now the problem is I am only drawing lines when I should be drawing semi planes ( x + y <=12 with x and y >0 , actually a filled triangle)



What I want to achieve:



drawing



Can you help me out?










share|improve this question


















  • 1





    I'm sure I've answered something like this before.....

    – cmhughes
    Dec 27 '18 at 19:53











  • so all the answers bellow helped me a lot , how can I accept more than one? Thank you guys for the quick and helpful replies.

    – random_numbers
    Dec 28 '18 at 7:54






  • 1





    Great! It's only possible to accept 1. As the OP, it's your within your gift to choose the answer that helped you the most :)

    – cmhughes
    Dec 28 '18 at 7:56
















4















I am a beginner in latex , but I am learning as I go, I want to plot the following linear programing problem:



(plot : to make a graphic)



f(x,y) = 2x - 3y -> max

x + y <= 12

x,y >=0


here is what I have so far, but I can`t find any good answers on how to draw in latex:



documentclass[12pt]{article}
usepackage{amsmath}
usepackage{graphicx}
usepackage{pgfplots}
usepackage{tikz}
usepackage{hyperref}
usepackage[latin1]{inputenc}


title{Linear Programming}
date{12/27/18}

begin{document}
maketitle

bigbreak
a) begin{cases} f(x,y) = 2x - 3y rightarrow max \x + y leq 12 \ x , y geq 0 end{cases}

bigbreak
bigbreak

begin{tikzpicture}
begin{axis}
[
xmin=-20,xmax=20,
ymin=-20,ymax=20,
grid=both,
grid style={line width=.1pt, draw=darkgray!10},
major grid style={line width=.2pt,draw=darkgray!50},
axis lines=middle,
minor tick num=4,
enlargelimits={abs=0.5},
axis line style={latex-latex},
samples=100,
domain = -20:20,
]
addplot[red] {x + y <= 12};

end{axis}
end{tikzpicture}


end{document}


Now the problem is I am only drawing lines when I should be drawing semi planes ( x + y <=12 with x and y >0 , actually a filled triangle)



What I want to achieve:



drawing



Can you help me out?










share|improve this question


















  • 1





    I'm sure I've answered something like this before.....

    – cmhughes
    Dec 27 '18 at 19:53











  • so all the answers bellow helped me a lot , how can I accept more than one? Thank you guys for the quick and helpful replies.

    – random_numbers
    Dec 28 '18 at 7:54






  • 1





    Great! It's only possible to accept 1. As the OP, it's your within your gift to choose the answer that helped you the most :)

    – cmhughes
    Dec 28 '18 at 7:56














4












4








4


2






I am a beginner in latex , but I am learning as I go, I want to plot the following linear programing problem:



(plot : to make a graphic)



f(x,y) = 2x - 3y -> max

x + y <= 12

x,y >=0


here is what I have so far, but I can`t find any good answers on how to draw in latex:



documentclass[12pt]{article}
usepackage{amsmath}
usepackage{graphicx}
usepackage{pgfplots}
usepackage{tikz}
usepackage{hyperref}
usepackage[latin1]{inputenc}


title{Linear Programming}
date{12/27/18}

begin{document}
maketitle

bigbreak
a) begin{cases} f(x,y) = 2x - 3y rightarrow max \x + y leq 12 \ x , y geq 0 end{cases}

bigbreak
bigbreak

begin{tikzpicture}
begin{axis}
[
xmin=-20,xmax=20,
ymin=-20,ymax=20,
grid=both,
grid style={line width=.1pt, draw=darkgray!10},
major grid style={line width=.2pt,draw=darkgray!50},
axis lines=middle,
minor tick num=4,
enlargelimits={abs=0.5},
axis line style={latex-latex},
samples=100,
domain = -20:20,
]
addplot[red] {x + y <= 12};

end{axis}
end{tikzpicture}


end{document}


Now the problem is I am only drawing lines when I should be drawing semi planes ( x + y <=12 with x and y >0 , actually a filled triangle)



What I want to achieve:



drawing



Can you help me out?










share|improve this question














I am a beginner in latex , but I am learning as I go, I want to plot the following linear programing problem:



(plot : to make a graphic)



f(x,y) = 2x - 3y -> max

x + y <= 12

x,y >=0


here is what I have so far, but I can`t find any good answers on how to draw in latex:



documentclass[12pt]{article}
usepackage{amsmath}
usepackage{graphicx}
usepackage{pgfplots}
usepackage{tikz}
usepackage{hyperref}
usepackage[latin1]{inputenc}


title{Linear Programming}
date{12/27/18}

begin{document}
maketitle

bigbreak
a) begin{cases} f(x,y) = 2x - 3y rightarrow max \x + y leq 12 \ x , y geq 0 end{cases}

bigbreak
bigbreak

begin{tikzpicture}
begin{axis}
[
xmin=-20,xmax=20,
ymin=-20,ymax=20,
grid=both,
grid style={line width=.1pt, draw=darkgray!10},
major grid style={line width=.2pt,draw=darkgray!50},
axis lines=middle,
minor tick num=4,
enlargelimits={abs=0.5},
axis line style={latex-latex},
samples=100,
domain = -20:20,
]
addplot[red] {x + y <= 12};

end{axis}
end{tikzpicture}


end{document}


Now the problem is I am only drawing lines when I should be drawing semi planes ( x + y <=12 with x and y >0 , actually a filled triangle)



What I want to achieve:



drawing



Can you help me out?







plot graphs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 27 '18 at 18:57









random_numbersrandom_numbers

234




234








  • 1





    I'm sure I've answered something like this before.....

    – cmhughes
    Dec 27 '18 at 19:53











  • so all the answers bellow helped me a lot , how can I accept more than one? Thank you guys for the quick and helpful replies.

    – random_numbers
    Dec 28 '18 at 7:54






  • 1





    Great! It's only possible to accept 1. As the OP, it's your within your gift to choose the answer that helped you the most :)

    – cmhughes
    Dec 28 '18 at 7:56














  • 1





    I'm sure I've answered something like this before.....

    – cmhughes
    Dec 27 '18 at 19:53











  • so all the answers bellow helped me a lot , how can I accept more than one? Thank you guys for the quick and helpful replies.

    – random_numbers
    Dec 28 '18 at 7:54






  • 1





    Great! It's only possible to accept 1. As the OP, it's your within your gift to choose the answer that helped you the most :)

    – cmhughes
    Dec 28 '18 at 7:56








1




1





I'm sure I've answered something like this before.....

– cmhughes
Dec 27 '18 at 19:53





I'm sure I've answered something like this before.....

– cmhughes
Dec 27 '18 at 19:53













so all the answers bellow helped me a lot , how can I accept more than one? Thank you guys for the quick and helpful replies.

– random_numbers
Dec 28 '18 at 7:54





so all the answers bellow helped me a lot , how can I accept more than one? Thank you guys for the quick and helpful replies.

– random_numbers
Dec 28 '18 at 7:54




1




1





Great! It's only possible to accept 1. As the OP, it's your within your gift to choose the answer that helped you the most :)

– cmhughes
Dec 28 '18 at 7:56





Great! It's only possible to accept 1. As the OP, it's your within your gift to choose the answer that helped you the most :)

– cmhughes
Dec 28 '18 at 7:56










3 Answers
3






active

oldest

votes


















6














You could use filldraw from vanilla tikz to draw + fill the region. Here's an example



documentclass[12pt]{article}
usepackage{amsmath}
usepackage{graphicx}
usepackage{pgfplots}
usepackage{tikz}
usepackage{hyperref}
usepackage[latin1]{inputenc}

pgfplotsset{compat=1.12}
usetikzlibrary{patterns}


title{Linear Programming}
author{Random Numbers}
date{12/27/18}

begin{document}
maketitle

[
begin{cases} f(x,y) = 2x - 3y rightarrow max \x + y leq 12 \ x , y geq 0 end{cases}
]
bigbreak
bigbreak

begin{tikzpicture}
begin{axis}
[
xmin=-5,xmax=15,
ymin=-5,ymax=15,
grid=both,
grid style={line width=.1pt, draw=darkgray!10},
major grid style={line width=.2pt,draw=darkgray!50},
axis lines=middle,
minor tick num=4,
enlargelimits={abs=0.5},
axis line style={latex-latex},
samples=100,
domain = -20:20,
]
%addplot[red] {x + y 12};
filldraw[blue, pattern=north west lines, pattern color=blue] (0, 0) -- (0, 12) -- (12, 0) -- cycle;
end{axis}
end{tikzpicture}


enter image description here






share|improve this answer































    6














    A PSTricks solution only for fun purposes.



    documentclass[pstricks,border=12pt,12pt]{standalone}
    usepackage{pst-plot}
    begin{document}
    pspicture(-1,-1)(13,13)
    psaxes[Dx=2,Dy=2]{->}(0,0)(-1,-1)(12.5,12.5)[$x$,0][$y$,90]
    pspolygon[fillstyle=vlines,hatchsep=3pt,hatchangle=30](0,0)(12,0)(0,12)
    pcline[nodesep=-1](12,0)(0,12)
    endpspicture
    end{document}


    enter image description here



    Miscellaneous



    documentclass[pstricks,border=12pt]{standalone}
    defRightPart
    {
    psline(0.5,2.7)(!6.5 3.5 82 PtoCab)
    psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
    psbezier(3.0,1.0)(3.0,2.2)(!6.5 3.5 73 PtoCab)
    psellipticarcn(6.5,3.5){(!6.5 3.5 73 PtoCab)}{(!6.5 3.5 73 neg PtoCab)}
    psbezier(4,-2)(4,0)(2.2,-1.8)
    psbezier(1.5,-1)(1,-1)(!6.5 3.5 -90 PtoCab)
    }

    begin{document}
    begin{pspicture}(-7,-4)(7,4)
    pscustom[dimen=m,linejoin=0,fillstyle=vlines]
    {
    RightPart
    reversepath
    scale{-1 1}
    RightPart
    closepath
    }
    end{pspicture}
    end{document}


    enter image description here






    share|improve this answer





















    • 2





      Ok, now you're just showing off :) (+1)

      – caverac
      Dec 27 '18 at 20:23











    • maybe showing on

      – The Inventor of God
      Dec 28 '18 at 10:57



















    5














    Very similar to caverac's nice answer except that this really uses a function, i.e. also works when the constraint is more complex.



    documentclass[12pt]{article}
    usepackage{amsmath}
    usepackage{tikz}
    usetikzlibrary{patterns}
    usepackage{pgfplots}
    pgfplotsset{compat=1.16}
    usepackage{hyperref}
    usepackage[latin1]{inputenc}


    title{Linear Programming}
    date{12/27/18}

    begin{document}
    maketitle

    a) $begin{cases} f(x,y) = 2x - 3y rightarrow text{max} \x + y leq 12 \ x ,
    y geq 0 end{cases}$


    begin{tikzpicture}
    begin{axis}
    [
    xmin=-20,xmax=20,
    ymin=-20,ymax=20,
    grid=both,
    grid style={line width=.1pt, draw=darkgray!10},
    major grid style={line width=.2pt,draw=darkgray!50},
    axis lines=middle,
    minor tick num=4,
    enlargelimits={abs=0.5},
    axis line style={latex-latex},
    samples=100,
    domain = -20:20,
    ]
    addplot[red,pattern=north east lines,pattern color=red] {12-x} -- (-20,-8) closedcycle;

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


    enter image description here






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "85"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467586%2fplotting-a-linear-programming-problem%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      6














      You could use filldraw from vanilla tikz to draw + fill the region. Here's an example



      documentclass[12pt]{article}
      usepackage{amsmath}
      usepackage{graphicx}
      usepackage{pgfplots}
      usepackage{tikz}
      usepackage{hyperref}
      usepackage[latin1]{inputenc}

      pgfplotsset{compat=1.12}
      usetikzlibrary{patterns}


      title{Linear Programming}
      author{Random Numbers}
      date{12/27/18}

      begin{document}
      maketitle

      [
      begin{cases} f(x,y) = 2x - 3y rightarrow max \x + y leq 12 \ x , y geq 0 end{cases}
      ]
      bigbreak
      bigbreak

      begin{tikzpicture}
      begin{axis}
      [
      xmin=-5,xmax=15,
      ymin=-5,ymax=15,
      grid=both,
      grid style={line width=.1pt, draw=darkgray!10},
      major grid style={line width=.2pt,draw=darkgray!50},
      axis lines=middle,
      minor tick num=4,
      enlargelimits={abs=0.5},
      axis line style={latex-latex},
      samples=100,
      domain = -20:20,
      ]
      %addplot[red] {x + y 12};
      filldraw[blue, pattern=north west lines, pattern color=blue] (0, 0) -- (0, 12) -- (12, 0) -- cycle;
      end{axis}
      end{tikzpicture}


      enter image description here






      share|improve this answer




























        6














        You could use filldraw from vanilla tikz to draw + fill the region. Here's an example



        documentclass[12pt]{article}
        usepackage{amsmath}
        usepackage{graphicx}
        usepackage{pgfplots}
        usepackage{tikz}
        usepackage{hyperref}
        usepackage[latin1]{inputenc}

        pgfplotsset{compat=1.12}
        usetikzlibrary{patterns}


        title{Linear Programming}
        author{Random Numbers}
        date{12/27/18}

        begin{document}
        maketitle

        [
        begin{cases} f(x,y) = 2x - 3y rightarrow max \x + y leq 12 \ x , y geq 0 end{cases}
        ]
        bigbreak
        bigbreak

        begin{tikzpicture}
        begin{axis}
        [
        xmin=-5,xmax=15,
        ymin=-5,ymax=15,
        grid=both,
        grid style={line width=.1pt, draw=darkgray!10},
        major grid style={line width=.2pt,draw=darkgray!50},
        axis lines=middle,
        minor tick num=4,
        enlargelimits={abs=0.5},
        axis line style={latex-latex},
        samples=100,
        domain = -20:20,
        ]
        %addplot[red] {x + y 12};
        filldraw[blue, pattern=north west lines, pattern color=blue] (0, 0) -- (0, 12) -- (12, 0) -- cycle;
        end{axis}
        end{tikzpicture}


        enter image description here






        share|improve this answer


























          6












          6








          6







          You could use filldraw from vanilla tikz to draw + fill the region. Here's an example



          documentclass[12pt]{article}
          usepackage{amsmath}
          usepackage{graphicx}
          usepackage{pgfplots}
          usepackage{tikz}
          usepackage{hyperref}
          usepackage[latin1]{inputenc}

          pgfplotsset{compat=1.12}
          usetikzlibrary{patterns}


          title{Linear Programming}
          author{Random Numbers}
          date{12/27/18}

          begin{document}
          maketitle

          [
          begin{cases} f(x,y) = 2x - 3y rightarrow max \x + y leq 12 \ x , y geq 0 end{cases}
          ]
          bigbreak
          bigbreak

          begin{tikzpicture}
          begin{axis}
          [
          xmin=-5,xmax=15,
          ymin=-5,ymax=15,
          grid=both,
          grid style={line width=.1pt, draw=darkgray!10},
          major grid style={line width=.2pt,draw=darkgray!50},
          axis lines=middle,
          minor tick num=4,
          enlargelimits={abs=0.5},
          axis line style={latex-latex},
          samples=100,
          domain = -20:20,
          ]
          %addplot[red] {x + y 12};
          filldraw[blue, pattern=north west lines, pattern color=blue] (0, 0) -- (0, 12) -- (12, 0) -- cycle;
          end{axis}
          end{tikzpicture}


          enter image description here






          share|improve this answer













          You could use filldraw from vanilla tikz to draw + fill the region. Here's an example



          documentclass[12pt]{article}
          usepackage{amsmath}
          usepackage{graphicx}
          usepackage{pgfplots}
          usepackage{tikz}
          usepackage{hyperref}
          usepackage[latin1]{inputenc}

          pgfplotsset{compat=1.12}
          usetikzlibrary{patterns}


          title{Linear Programming}
          author{Random Numbers}
          date{12/27/18}

          begin{document}
          maketitle

          [
          begin{cases} f(x,y) = 2x - 3y rightarrow max \x + y leq 12 \ x , y geq 0 end{cases}
          ]
          bigbreak
          bigbreak

          begin{tikzpicture}
          begin{axis}
          [
          xmin=-5,xmax=15,
          ymin=-5,ymax=15,
          grid=both,
          grid style={line width=.1pt, draw=darkgray!10},
          major grid style={line width=.2pt,draw=darkgray!50},
          axis lines=middle,
          minor tick num=4,
          enlargelimits={abs=0.5},
          axis line style={latex-latex},
          samples=100,
          domain = -20:20,
          ]
          %addplot[red] {x + y 12};
          filldraw[blue, pattern=north west lines, pattern color=blue] (0, 0) -- (0, 12) -- (12, 0) -- cycle;
          end{axis}
          end{tikzpicture}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 27 '18 at 19:28









          caveraccaverac

          6,6571827




          6,6571827























              6














              A PSTricks solution only for fun purposes.



              documentclass[pstricks,border=12pt,12pt]{standalone}
              usepackage{pst-plot}
              begin{document}
              pspicture(-1,-1)(13,13)
              psaxes[Dx=2,Dy=2]{->}(0,0)(-1,-1)(12.5,12.5)[$x$,0][$y$,90]
              pspolygon[fillstyle=vlines,hatchsep=3pt,hatchangle=30](0,0)(12,0)(0,12)
              pcline[nodesep=-1](12,0)(0,12)
              endpspicture
              end{document}


              enter image description here



              Miscellaneous



              documentclass[pstricks,border=12pt]{standalone}
              defRightPart
              {
              psline(0.5,2.7)(!6.5 3.5 82 PtoCab)
              psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
              psbezier(3.0,1.0)(3.0,2.2)(!6.5 3.5 73 PtoCab)
              psellipticarcn(6.5,3.5){(!6.5 3.5 73 PtoCab)}{(!6.5 3.5 73 neg PtoCab)}
              psbezier(4,-2)(4,0)(2.2,-1.8)
              psbezier(1.5,-1)(1,-1)(!6.5 3.5 -90 PtoCab)
              }

              begin{document}
              begin{pspicture}(-7,-4)(7,4)
              pscustom[dimen=m,linejoin=0,fillstyle=vlines]
              {
              RightPart
              reversepath
              scale{-1 1}
              RightPart
              closepath
              }
              end{pspicture}
              end{document}


              enter image description here






              share|improve this answer





















              • 2





                Ok, now you're just showing off :) (+1)

                – caverac
                Dec 27 '18 at 20:23











              • maybe showing on

                – The Inventor of God
                Dec 28 '18 at 10:57
















              6














              A PSTricks solution only for fun purposes.



              documentclass[pstricks,border=12pt,12pt]{standalone}
              usepackage{pst-plot}
              begin{document}
              pspicture(-1,-1)(13,13)
              psaxes[Dx=2,Dy=2]{->}(0,0)(-1,-1)(12.5,12.5)[$x$,0][$y$,90]
              pspolygon[fillstyle=vlines,hatchsep=3pt,hatchangle=30](0,0)(12,0)(0,12)
              pcline[nodesep=-1](12,0)(0,12)
              endpspicture
              end{document}


              enter image description here



              Miscellaneous



              documentclass[pstricks,border=12pt]{standalone}
              defRightPart
              {
              psline(0.5,2.7)(!6.5 3.5 82 PtoCab)
              psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
              psbezier(3.0,1.0)(3.0,2.2)(!6.5 3.5 73 PtoCab)
              psellipticarcn(6.5,3.5){(!6.5 3.5 73 PtoCab)}{(!6.5 3.5 73 neg PtoCab)}
              psbezier(4,-2)(4,0)(2.2,-1.8)
              psbezier(1.5,-1)(1,-1)(!6.5 3.5 -90 PtoCab)
              }

              begin{document}
              begin{pspicture}(-7,-4)(7,4)
              pscustom[dimen=m,linejoin=0,fillstyle=vlines]
              {
              RightPart
              reversepath
              scale{-1 1}
              RightPart
              closepath
              }
              end{pspicture}
              end{document}


              enter image description here






              share|improve this answer





















              • 2





                Ok, now you're just showing off :) (+1)

                – caverac
                Dec 27 '18 at 20:23











              • maybe showing on

                – The Inventor of God
                Dec 28 '18 at 10:57














              6












              6








              6







              A PSTricks solution only for fun purposes.



              documentclass[pstricks,border=12pt,12pt]{standalone}
              usepackage{pst-plot}
              begin{document}
              pspicture(-1,-1)(13,13)
              psaxes[Dx=2,Dy=2]{->}(0,0)(-1,-1)(12.5,12.5)[$x$,0][$y$,90]
              pspolygon[fillstyle=vlines,hatchsep=3pt,hatchangle=30](0,0)(12,0)(0,12)
              pcline[nodesep=-1](12,0)(0,12)
              endpspicture
              end{document}


              enter image description here



              Miscellaneous



              documentclass[pstricks,border=12pt]{standalone}
              defRightPart
              {
              psline(0.5,2.7)(!6.5 3.5 82 PtoCab)
              psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
              psbezier(3.0,1.0)(3.0,2.2)(!6.5 3.5 73 PtoCab)
              psellipticarcn(6.5,3.5){(!6.5 3.5 73 PtoCab)}{(!6.5 3.5 73 neg PtoCab)}
              psbezier(4,-2)(4,0)(2.2,-1.8)
              psbezier(1.5,-1)(1,-1)(!6.5 3.5 -90 PtoCab)
              }

              begin{document}
              begin{pspicture}(-7,-4)(7,4)
              pscustom[dimen=m,linejoin=0,fillstyle=vlines]
              {
              RightPart
              reversepath
              scale{-1 1}
              RightPart
              closepath
              }
              end{pspicture}
              end{document}


              enter image description here






              share|improve this answer















              A PSTricks solution only for fun purposes.



              documentclass[pstricks,border=12pt,12pt]{standalone}
              usepackage{pst-plot}
              begin{document}
              pspicture(-1,-1)(13,13)
              psaxes[Dx=2,Dy=2]{->}(0,0)(-1,-1)(12.5,12.5)[$x$,0][$y$,90]
              pspolygon[fillstyle=vlines,hatchsep=3pt,hatchangle=30](0,0)(12,0)(0,12)
              pcline[nodesep=-1](12,0)(0,12)
              endpspicture
              end{document}


              enter image description here



              Miscellaneous



              documentclass[pstricks,border=12pt]{standalone}
              defRightPart
              {
              psline(0.5,2.7)(!6.5 3.5 82 PtoCab)
              psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
              psbezier(3.0,1.0)(3.0,2.2)(!6.5 3.5 73 PtoCab)
              psellipticarcn(6.5,3.5){(!6.5 3.5 73 PtoCab)}{(!6.5 3.5 73 neg PtoCab)}
              psbezier(4,-2)(4,0)(2.2,-1.8)
              psbezier(1.5,-1)(1,-1)(!6.5 3.5 -90 PtoCab)
              }

              begin{document}
              begin{pspicture}(-7,-4)(7,4)
              pscustom[dimen=m,linejoin=0,fillstyle=vlines]
              {
              RightPart
              reversepath
              scale{-1 1}
              RightPart
              closepath
              }
              end{pspicture}
              end{document}


              enter image description here







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 27 '18 at 20:06

























              answered Dec 27 '18 at 19:07









              The Inventor of GodThe Inventor of God

              4,90611142




              4,90611142








              • 2





                Ok, now you're just showing off :) (+1)

                – caverac
                Dec 27 '18 at 20:23











              • maybe showing on

                – The Inventor of God
                Dec 28 '18 at 10:57














              • 2





                Ok, now you're just showing off :) (+1)

                – caverac
                Dec 27 '18 at 20:23











              • maybe showing on

                – The Inventor of God
                Dec 28 '18 at 10:57








              2




              2





              Ok, now you're just showing off :) (+1)

              – caverac
              Dec 27 '18 at 20:23





              Ok, now you're just showing off :) (+1)

              – caverac
              Dec 27 '18 at 20:23













              maybe showing on

              – The Inventor of God
              Dec 28 '18 at 10:57





              maybe showing on

              – The Inventor of God
              Dec 28 '18 at 10:57











              5














              Very similar to caverac's nice answer except that this really uses a function, i.e. also works when the constraint is more complex.



              documentclass[12pt]{article}
              usepackage{amsmath}
              usepackage{tikz}
              usetikzlibrary{patterns}
              usepackage{pgfplots}
              pgfplotsset{compat=1.16}
              usepackage{hyperref}
              usepackage[latin1]{inputenc}


              title{Linear Programming}
              date{12/27/18}

              begin{document}
              maketitle

              a) $begin{cases} f(x,y) = 2x - 3y rightarrow text{max} \x + y leq 12 \ x ,
              y geq 0 end{cases}$


              begin{tikzpicture}
              begin{axis}
              [
              xmin=-20,xmax=20,
              ymin=-20,ymax=20,
              grid=both,
              grid style={line width=.1pt, draw=darkgray!10},
              major grid style={line width=.2pt,draw=darkgray!50},
              axis lines=middle,
              minor tick num=4,
              enlargelimits={abs=0.5},
              axis line style={latex-latex},
              samples=100,
              domain = -20:20,
              ]
              addplot[red,pattern=north east lines,pattern color=red] {12-x} -- (-20,-8) closedcycle;

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


              enter image description here






              share|improve this answer




























                5














                Very similar to caverac's nice answer except that this really uses a function, i.e. also works when the constraint is more complex.



                documentclass[12pt]{article}
                usepackage{amsmath}
                usepackage{tikz}
                usetikzlibrary{patterns}
                usepackage{pgfplots}
                pgfplotsset{compat=1.16}
                usepackage{hyperref}
                usepackage[latin1]{inputenc}


                title{Linear Programming}
                date{12/27/18}

                begin{document}
                maketitle

                a) $begin{cases} f(x,y) = 2x - 3y rightarrow text{max} \x + y leq 12 \ x ,
                y geq 0 end{cases}$


                begin{tikzpicture}
                begin{axis}
                [
                xmin=-20,xmax=20,
                ymin=-20,ymax=20,
                grid=both,
                grid style={line width=.1pt, draw=darkgray!10},
                major grid style={line width=.2pt,draw=darkgray!50},
                axis lines=middle,
                minor tick num=4,
                enlargelimits={abs=0.5},
                axis line style={latex-latex},
                samples=100,
                domain = -20:20,
                ]
                addplot[red,pattern=north east lines,pattern color=red] {12-x} -- (-20,-8) closedcycle;

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


                enter image description here






                share|improve this answer


























                  5












                  5








                  5







                  Very similar to caverac's nice answer except that this really uses a function, i.e. also works when the constraint is more complex.



                  documentclass[12pt]{article}
                  usepackage{amsmath}
                  usepackage{tikz}
                  usetikzlibrary{patterns}
                  usepackage{pgfplots}
                  pgfplotsset{compat=1.16}
                  usepackage{hyperref}
                  usepackage[latin1]{inputenc}


                  title{Linear Programming}
                  date{12/27/18}

                  begin{document}
                  maketitle

                  a) $begin{cases} f(x,y) = 2x - 3y rightarrow text{max} \x + y leq 12 \ x ,
                  y geq 0 end{cases}$


                  begin{tikzpicture}
                  begin{axis}
                  [
                  xmin=-20,xmax=20,
                  ymin=-20,ymax=20,
                  grid=both,
                  grid style={line width=.1pt, draw=darkgray!10},
                  major grid style={line width=.2pt,draw=darkgray!50},
                  axis lines=middle,
                  minor tick num=4,
                  enlargelimits={abs=0.5},
                  axis line style={latex-latex},
                  samples=100,
                  domain = -20:20,
                  ]
                  addplot[red,pattern=north east lines,pattern color=red] {12-x} -- (-20,-8) closedcycle;

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


                  enter image description here






                  share|improve this answer













                  Very similar to caverac's nice answer except that this really uses a function, i.e. also works when the constraint is more complex.



                  documentclass[12pt]{article}
                  usepackage{amsmath}
                  usepackage{tikz}
                  usetikzlibrary{patterns}
                  usepackage{pgfplots}
                  pgfplotsset{compat=1.16}
                  usepackage{hyperref}
                  usepackage[latin1]{inputenc}


                  title{Linear Programming}
                  date{12/27/18}

                  begin{document}
                  maketitle

                  a) $begin{cases} f(x,y) = 2x - 3y rightarrow text{max} \x + y leq 12 \ x ,
                  y geq 0 end{cases}$


                  begin{tikzpicture}
                  begin{axis}
                  [
                  xmin=-20,xmax=20,
                  ymin=-20,ymax=20,
                  grid=both,
                  grid style={line width=.1pt, draw=darkgray!10},
                  major grid style={line width=.2pt,draw=darkgray!50},
                  axis lines=middle,
                  minor tick num=4,
                  enlargelimits={abs=0.5},
                  axis line style={latex-latex},
                  samples=100,
                  domain = -20:20,
                  ]
                  addplot[red,pattern=north east lines,pattern color=red] {12-x} -- (-20,-8) closedcycle;

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


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 27 '18 at 19:35









                  marmotmarmot

                  109k5134252




                  109k5134252






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467586%2fplotting-a-linear-programming-problem%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      To store a contact into the json file from server.js file using a class in NodeJS

                      Redirect URL with Chrome Remote Debugging Android Devices

                      Dieringhausen