How to raster area bounded by two functions?












4














This code works normally:



documentclass[pstricks]{standalone}
usepackage{pst-plot}
%usepackage{auto-pst-pdf}% only for pdflatex
begin{pspicture}[algebraic,linestyle=curve](-2,-6)(6,6)
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
psclip{%
psplot[linestyle=none]{0}{6.5}{x*(3-x)/2}}
psplot[linecolor=blue,fillstyle=vlines]{.5}{5}{x*(x-6)+6}
endpsclip
psplot{0}{4.5}{x*(3-x)/2}}
psplot[linecolor=blue]{.5}{5}{x*(x-6)+6}
rput[bl](1.8,1.2){$y=dfrac{-x^2+3x}{2}$}
rput[t](2,-3.1){$y=x^2-6x+6$}
end{pspicture}
end{document}


enter image description here



but the following code is not working:



documentclass[pstricks]{standalone}
usepackage{pst-plot}
%usepackage{auto-pst-pdf}% only for pdflatex
begin{pspicture}[algebraic,linestyle=curve](-2,-6)(6,6)
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
psclip{%
psplot[linecolor=blue,]{-1}{5}{-1*x+2}}
psplot[fillstyle=hlines]{.5}{5}{x*(x-6)+6}
endpsclip
psplot[linewidth=1.5pt]{.5}{5}{x*(x-6)+6}
rput[bl](1.5,1){$y=-x+2$}
rput[t](2,-3.1){$y=x^2-6x+6$}
end{pspicture}
end{document}


enter image description here










share|improve this question




















  • 2




    Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
    – Andrew
    Nov 20 '18 at 8:30










  • Thank you for your remind.
    – chishimotoji
    Nov 20 '18 at 8:40










  • You should remove everything from the example code which is not important for the problem, e.g. the margin setting, amsmath, a lot of the PSTricks packages, graphicx
    – Herbert
    Nov 20 '18 at 9:22










  • @Herbert: I do so since I hope while compiling not having error.
    – chishimotoji
    Nov 20 '18 at 9:30








  • 1




    linestyle=curve should be plotstyle=curve
    – Herbert
    Nov 20 '18 at 10:57
















4














This code works normally:



documentclass[pstricks]{standalone}
usepackage{pst-plot}
%usepackage{auto-pst-pdf}% only for pdflatex
begin{pspicture}[algebraic,linestyle=curve](-2,-6)(6,6)
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
psclip{%
psplot[linestyle=none]{0}{6.5}{x*(3-x)/2}}
psplot[linecolor=blue,fillstyle=vlines]{.5}{5}{x*(x-6)+6}
endpsclip
psplot{0}{4.5}{x*(3-x)/2}}
psplot[linecolor=blue]{.5}{5}{x*(x-6)+6}
rput[bl](1.8,1.2){$y=dfrac{-x^2+3x}{2}$}
rput[t](2,-3.1){$y=x^2-6x+6$}
end{pspicture}
end{document}


enter image description here



but the following code is not working:



documentclass[pstricks]{standalone}
usepackage{pst-plot}
%usepackage{auto-pst-pdf}% only for pdflatex
begin{pspicture}[algebraic,linestyle=curve](-2,-6)(6,6)
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
psclip{%
psplot[linecolor=blue,]{-1}{5}{-1*x+2}}
psplot[fillstyle=hlines]{.5}{5}{x*(x-6)+6}
endpsclip
psplot[linewidth=1.5pt]{.5}{5}{x*(x-6)+6}
rput[bl](1.5,1){$y=-x+2$}
rput[t](2,-3.1){$y=x^2-6x+6$}
end{pspicture}
end{document}


enter image description here










share|improve this question




















  • 2




    Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
    – Andrew
    Nov 20 '18 at 8:30










  • Thank you for your remind.
    – chishimotoji
    Nov 20 '18 at 8:40










  • You should remove everything from the example code which is not important for the problem, e.g. the margin setting, amsmath, a lot of the PSTricks packages, graphicx
    – Herbert
    Nov 20 '18 at 9:22










  • @Herbert: I do so since I hope while compiling not having error.
    – chishimotoji
    Nov 20 '18 at 9:30








  • 1




    linestyle=curve should be plotstyle=curve
    – Herbert
    Nov 20 '18 at 10:57














4












4








4







This code works normally:



documentclass[pstricks]{standalone}
usepackage{pst-plot}
%usepackage{auto-pst-pdf}% only for pdflatex
begin{pspicture}[algebraic,linestyle=curve](-2,-6)(6,6)
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
psclip{%
psplot[linestyle=none]{0}{6.5}{x*(3-x)/2}}
psplot[linecolor=blue,fillstyle=vlines]{.5}{5}{x*(x-6)+6}
endpsclip
psplot{0}{4.5}{x*(3-x)/2}}
psplot[linecolor=blue]{.5}{5}{x*(x-6)+6}
rput[bl](1.8,1.2){$y=dfrac{-x^2+3x}{2}$}
rput[t](2,-3.1){$y=x^2-6x+6$}
end{pspicture}
end{document}


enter image description here



but the following code is not working:



documentclass[pstricks]{standalone}
usepackage{pst-plot}
%usepackage{auto-pst-pdf}% only for pdflatex
begin{pspicture}[algebraic,linestyle=curve](-2,-6)(6,6)
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
psclip{%
psplot[linecolor=blue,]{-1}{5}{-1*x+2}}
psplot[fillstyle=hlines]{.5}{5}{x*(x-6)+6}
endpsclip
psplot[linewidth=1.5pt]{.5}{5}{x*(x-6)+6}
rput[bl](1.5,1){$y=-x+2$}
rput[t](2,-3.1){$y=x^2-6x+6$}
end{pspicture}
end{document}


enter image description here










share|improve this question















This code works normally:



documentclass[pstricks]{standalone}
usepackage{pst-plot}
%usepackage{auto-pst-pdf}% only for pdflatex
begin{pspicture}[algebraic,linestyle=curve](-2,-6)(6,6)
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
psclip{%
psplot[linestyle=none]{0}{6.5}{x*(3-x)/2}}
psplot[linecolor=blue,fillstyle=vlines]{.5}{5}{x*(x-6)+6}
endpsclip
psplot{0}{4.5}{x*(3-x)/2}}
psplot[linecolor=blue]{.5}{5}{x*(x-6)+6}
rput[bl](1.8,1.2){$y=dfrac{-x^2+3x}{2}$}
rput[t](2,-3.1){$y=x^2-6x+6$}
end{pspicture}
end{document}


enter image description here



but the following code is not working:



documentclass[pstricks]{standalone}
usepackage{pst-plot}
%usepackage{auto-pst-pdf}% only for pdflatex
begin{pspicture}[algebraic,linestyle=curve](-2,-6)(6,6)
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
psclip{%
psplot[linecolor=blue,]{-1}{5}{-1*x+2}}
psplot[fillstyle=hlines]{.5}{5}{x*(x-6)+6}
endpsclip
psplot[linewidth=1.5pt]{.5}{5}{x*(x-6)+6}
rput[bl](1.5,1){$y=-x+2$}
rput[t](2,-3.1){$y=x^2-6x+6$}
end{pspicture}
end{document}


enter image description here







pstricks pst-plot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 4:42

























asked Nov 20 '18 at 8:19









chishimotoji

837316




837316








  • 2




    Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
    – Andrew
    Nov 20 '18 at 8:30










  • Thank you for your remind.
    – chishimotoji
    Nov 20 '18 at 8:40










  • You should remove everything from the example code which is not important for the problem, e.g. the margin setting, amsmath, a lot of the PSTricks packages, graphicx
    – Herbert
    Nov 20 '18 at 9:22










  • @Herbert: I do so since I hope while compiling not having error.
    – chishimotoji
    Nov 20 '18 at 9:30








  • 1




    linestyle=curve should be plotstyle=curve
    – Herbert
    Nov 20 '18 at 10:57














  • 2




    Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
    – Andrew
    Nov 20 '18 at 8:30










  • Thank you for your remind.
    – chishimotoji
    Nov 20 '18 at 8:40










  • You should remove everything from the example code which is not important for the problem, e.g. the margin setting, amsmath, a lot of the PSTricks packages, graphicx
    – Herbert
    Nov 20 '18 at 9:22










  • @Herbert: I do so since I hope while compiling not having error.
    – chishimotoji
    Nov 20 '18 at 9:30








  • 1




    linestyle=curve should be plotstyle=curve
    – Herbert
    Nov 20 '18 at 10:57








2




2




Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
– Andrew
Nov 20 '18 at 8:30




Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
– Andrew
Nov 20 '18 at 8:30












Thank you for your remind.
– chishimotoji
Nov 20 '18 at 8:40




Thank you for your remind.
– chishimotoji
Nov 20 '18 at 8:40












You should remove everything from the example code which is not important for the problem, e.g. the margin setting, amsmath, a lot of the PSTricks packages, graphicx
– Herbert
Nov 20 '18 at 9:22




You should remove everything from the example code which is not important for the problem, e.g. the margin setting, amsmath, a lot of the PSTricks packages, graphicx
– Herbert
Nov 20 '18 at 9:22












@Herbert: I do so since I hope while compiling not having error.
– chishimotoji
Nov 20 '18 at 9:30






@Herbert: I do so since I hope while compiling not having error.
– chishimotoji
Nov 20 '18 at 9:30






1




1




linestyle=curve should be plotstyle=curve
– Herbert
Nov 20 '18 at 10:57




linestyle=curve should be plotstyle=curve
– Herbert
Nov 20 '18 at 10:57










2 Answers
2






active

oldest

votes


















4














You have to define an area which will then be clipped. The area is build with connecting the first point with the last one. For a line you simply get an area of zero, and from this area nothing can be clipped!



With psline(0,2)(5,-3)(0,-3) I define a triangle. It is automatically a closed area becasue it draws a line from (0,-3) to (0,2).
And from that area the curve with {x*(x-6)+6} is clipping a part which will be filled.



documentclass[pstricks]{standalone}
usepackage{pst-plot}
begin{document}

begin{pspicture}[algebraic,plotstyle=curve](-2,-6)(6,6)
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
psclip{psline[linestyle=none](0,2)(5,-3)(0,-3)}
psplot[fillstyle=vlines]{.5}{5}{x*(x-6)+6}
endpsclip
psplot[linewidth=1.5pt,linecolor=blue]{.5}{5}{x*(x-6)+6}
psline[linewidth=1.5pt](0,2)(5,-3)
rput[bl](1.5,1){$y=-x+2$}
rput[t](2,-3.1){$y=x^2-6x+6$}
end{pspicture}

end{document}


enter image description here



As an alternative you can calculate the intersectionpoints (needs package pst-intersect) and using pscustom



%%usepackage{pst-intersect} in the preamble
begin{pspicture}[algebraic](-2,-6)(6,6)
pssavepath[linewidth=1.5pt]{Curve}{psplot{.5}{5}{x*(x-6)+6}}
pssavepath[linewidth=1.5pt]{Line}{psplot{0}{5}{-x+2}}
psintersect[name=C]{Curve}{Line}
psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
pscustom[fillcolor=red,fillstyle=solid,opacity=0.4]{%
psplot{psGetNodeCenter{C1}C1.x}{psGetNodeCenter{C2}C2.x}{x*(x-6)+6}%
}
end{pspicture}


enter image description here



However, that one with pst-intersect works not with xelatex






share|improve this answer























  • I understanded what you directing. And together Artificial Stupidity's anwser, I have more knowledge myseft.
    – chishimotoji
    Nov 20 '18 at 9:23



















3














Generic Template



Proposed features:




  • functions are defined globally so you can change easily.

  • intersection points are calculated at "runtime" as opposed to statically hard coded.




documentclass[pstricks,border=12pt]{standalone}
usepackage{pst-eucl,pst-plot}


deff(#1){((#1)^2-6*(#1)+6)}
defg(#1){(2-(#1))}

begin{document}
begin{pspicture}[algebraic,saveNodeCoors,PointSymbol=none,PointName=none](-1,-3.5)(6,4)
psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
pstInterFF{f(x)}{g(x)}{0}{A}
pstInterFF{f(x)}{g(x)}{5}{B}
pscustom*[linecolor=yellow!50]{%
psplot{N-A.x}{N-B.x}{f(x)}
psplot{N-B.x}{N-A.x}{g(x)}
closepath
}
psset{linewidth=2pt,linecolor=cyan}
psplot{.5}{5}{f(x)}
psplot{-.5}{5}{g(x)}
uput[-90](*5 {g(x)}){$y=-x+2$}
uput[45](*.7 {f(x)}){$y=x^2-6x+6$}
end{pspicture}
end{document}


enter image description here



Statically hard-coded Version



Cons: you have to calculate the intersection points in advance by hands.



documentclass[pstricks,border=12pt]{standalone}
usepackage{pst-plot}

deff{x^2-6*x+6}
defg{2-x}

begin{document}
begin{pspicture}[algebraic](-1,-3.5)(6,4)
psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
pscustom[fillstyle=vlines,hatchcolor=red,hatchsep=0.8pt]{psplot{1}{4}{f}psplot{4}{1}{g}}
psset{linewidth=2pt,linecolor=blue}
psplot{.5}{5}{f}
psplot{-.5}{5}{g}
uput[-90](*5 {g}){$y=-x+2$}
uput[45](*.7 {f}){$y=x^2-6x+6$}
end{pspicture}
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%2f460890%2fhow-to-raster-area-bounded-by-two-functions%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    You have to define an area which will then be clipped. The area is build with connecting the first point with the last one. For a line you simply get an area of zero, and from this area nothing can be clipped!



    With psline(0,2)(5,-3)(0,-3) I define a triangle. It is automatically a closed area becasue it draws a line from (0,-3) to (0,2).
    And from that area the curve with {x*(x-6)+6} is clipping a part which will be filled.



    documentclass[pstricks]{standalone}
    usepackage{pst-plot}
    begin{document}

    begin{pspicture}[algebraic,plotstyle=curve](-2,-6)(6,6)
    psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
    psclip{psline[linestyle=none](0,2)(5,-3)(0,-3)}
    psplot[fillstyle=vlines]{.5}{5}{x*(x-6)+6}
    endpsclip
    psplot[linewidth=1.5pt,linecolor=blue]{.5}{5}{x*(x-6)+6}
    psline[linewidth=1.5pt](0,2)(5,-3)
    rput[bl](1.5,1){$y=-x+2$}
    rput[t](2,-3.1){$y=x^2-6x+6$}
    end{pspicture}

    end{document}


    enter image description here



    As an alternative you can calculate the intersectionpoints (needs package pst-intersect) and using pscustom



    %%usepackage{pst-intersect} in the preamble
    begin{pspicture}[algebraic](-2,-6)(6,6)
    pssavepath[linewidth=1.5pt]{Curve}{psplot{.5}{5}{x*(x-6)+6}}
    pssavepath[linewidth=1.5pt]{Line}{psplot{0}{5}{-x+2}}
    psintersect[name=C]{Curve}{Line}
    psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
    pscustom[fillcolor=red,fillstyle=solid,opacity=0.4]{%
    psplot{psGetNodeCenter{C1}C1.x}{psGetNodeCenter{C2}C2.x}{x*(x-6)+6}%
    }
    end{pspicture}


    enter image description here



    However, that one with pst-intersect works not with xelatex






    share|improve this answer























    • I understanded what you directing. And together Artificial Stupidity's anwser, I have more knowledge myseft.
      – chishimotoji
      Nov 20 '18 at 9:23
















    4














    You have to define an area which will then be clipped. The area is build with connecting the first point with the last one. For a line you simply get an area of zero, and from this area nothing can be clipped!



    With psline(0,2)(5,-3)(0,-3) I define a triangle. It is automatically a closed area becasue it draws a line from (0,-3) to (0,2).
    And from that area the curve with {x*(x-6)+6} is clipping a part which will be filled.



    documentclass[pstricks]{standalone}
    usepackage{pst-plot}
    begin{document}

    begin{pspicture}[algebraic,plotstyle=curve](-2,-6)(6,6)
    psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
    psclip{psline[linestyle=none](0,2)(5,-3)(0,-3)}
    psplot[fillstyle=vlines]{.5}{5}{x*(x-6)+6}
    endpsclip
    psplot[linewidth=1.5pt,linecolor=blue]{.5}{5}{x*(x-6)+6}
    psline[linewidth=1.5pt](0,2)(5,-3)
    rput[bl](1.5,1){$y=-x+2$}
    rput[t](2,-3.1){$y=x^2-6x+6$}
    end{pspicture}

    end{document}


    enter image description here



    As an alternative you can calculate the intersectionpoints (needs package pst-intersect) and using pscustom



    %%usepackage{pst-intersect} in the preamble
    begin{pspicture}[algebraic](-2,-6)(6,6)
    pssavepath[linewidth=1.5pt]{Curve}{psplot{.5}{5}{x*(x-6)+6}}
    pssavepath[linewidth=1.5pt]{Line}{psplot{0}{5}{-x+2}}
    psintersect[name=C]{Curve}{Line}
    psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
    pscustom[fillcolor=red,fillstyle=solid,opacity=0.4]{%
    psplot{psGetNodeCenter{C1}C1.x}{psGetNodeCenter{C2}C2.x}{x*(x-6)+6}%
    }
    end{pspicture}


    enter image description here



    However, that one with pst-intersect works not with xelatex






    share|improve this answer























    • I understanded what you directing. And together Artificial Stupidity's anwser, I have more knowledge myseft.
      – chishimotoji
      Nov 20 '18 at 9:23














    4












    4








    4






    You have to define an area which will then be clipped. The area is build with connecting the first point with the last one. For a line you simply get an area of zero, and from this area nothing can be clipped!



    With psline(0,2)(5,-3)(0,-3) I define a triangle. It is automatically a closed area becasue it draws a line from (0,-3) to (0,2).
    And from that area the curve with {x*(x-6)+6} is clipping a part which will be filled.



    documentclass[pstricks]{standalone}
    usepackage{pst-plot}
    begin{document}

    begin{pspicture}[algebraic,plotstyle=curve](-2,-6)(6,6)
    psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
    psclip{psline[linestyle=none](0,2)(5,-3)(0,-3)}
    psplot[fillstyle=vlines]{.5}{5}{x*(x-6)+6}
    endpsclip
    psplot[linewidth=1.5pt,linecolor=blue]{.5}{5}{x*(x-6)+6}
    psline[linewidth=1.5pt](0,2)(5,-3)
    rput[bl](1.5,1){$y=-x+2$}
    rput[t](2,-3.1){$y=x^2-6x+6$}
    end{pspicture}

    end{document}


    enter image description here



    As an alternative you can calculate the intersectionpoints (needs package pst-intersect) and using pscustom



    %%usepackage{pst-intersect} in the preamble
    begin{pspicture}[algebraic](-2,-6)(6,6)
    pssavepath[linewidth=1.5pt]{Curve}{psplot{.5}{5}{x*(x-6)+6}}
    pssavepath[linewidth=1.5pt]{Line}{psplot{0}{5}{-x+2}}
    psintersect[name=C]{Curve}{Line}
    psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
    pscustom[fillcolor=red,fillstyle=solid,opacity=0.4]{%
    psplot{psGetNodeCenter{C1}C1.x}{psGetNodeCenter{C2}C2.x}{x*(x-6)+6}%
    }
    end{pspicture}


    enter image description here



    However, that one with pst-intersect works not with xelatex






    share|improve this answer














    You have to define an area which will then be clipped. The area is build with connecting the first point with the last one. For a line you simply get an area of zero, and from this area nothing can be clipped!



    With psline(0,2)(5,-3)(0,-3) I define a triangle. It is automatically a closed area becasue it draws a line from (0,-3) to (0,2).
    And from that area the curve with {x*(x-6)+6} is clipping a part which will be filled.



    documentclass[pstricks]{standalone}
    usepackage{pst-plot}
    begin{document}

    begin{pspicture}[algebraic,plotstyle=curve](-2,-6)(6,6)
    psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
    psclip{psline[linestyle=none](0,2)(5,-3)(0,-3)}
    psplot[fillstyle=vlines]{.5}{5}{x*(x-6)+6}
    endpsclip
    psplot[linewidth=1.5pt,linecolor=blue]{.5}{5}{x*(x-6)+6}
    psline[linewidth=1.5pt](0,2)(5,-3)
    rput[bl](1.5,1){$y=-x+2$}
    rput[t](2,-3.1){$y=x^2-6x+6$}
    end{pspicture}

    end{document}


    enter image description here



    As an alternative you can calculate the intersectionpoints (needs package pst-intersect) and using pscustom



    %%usepackage{pst-intersect} in the preamble
    begin{pspicture}[algebraic](-2,-6)(6,6)
    pssavepath[linewidth=1.5pt]{Curve}{psplot{.5}{5}{x*(x-6)+6}}
    pssavepath[linewidth=1.5pt]{Line}{psplot{0}{5}{-x+2}}
    psintersect[name=C]{Curve}{Line}
    psaxes{->}(0,0)(-2,-4)(5.5,4)[$x$,0][$y$,90]
    pscustom[fillcolor=red,fillstyle=solid,opacity=0.4]{%
    psplot{psGetNodeCenter{C1}C1.x}{psGetNodeCenter{C2}C2.x}{x*(x-6)+6}%
    }
    end{pspicture}


    enter image description here



    However, that one with pst-intersect works not with xelatex







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 20 '18 at 9:41

























    answered Nov 20 '18 at 9:05









    Herbert

    269k24408717




    269k24408717












    • I understanded what you directing. And together Artificial Stupidity's anwser, I have more knowledge myseft.
      – chishimotoji
      Nov 20 '18 at 9:23


















    • I understanded what you directing. And together Artificial Stupidity's anwser, I have more knowledge myseft.
      – chishimotoji
      Nov 20 '18 at 9:23
















    I understanded what you directing. And together Artificial Stupidity's anwser, I have more knowledge myseft.
    – chishimotoji
    Nov 20 '18 at 9:23




    I understanded what you directing. And together Artificial Stupidity's anwser, I have more knowledge myseft.
    – chishimotoji
    Nov 20 '18 at 9:23











    3














    Generic Template



    Proposed features:




    • functions are defined globally so you can change easily.

    • intersection points are calculated at "runtime" as opposed to statically hard coded.




    documentclass[pstricks,border=12pt]{standalone}
    usepackage{pst-eucl,pst-plot}


    deff(#1){((#1)^2-6*(#1)+6)}
    defg(#1){(2-(#1))}

    begin{document}
    begin{pspicture}[algebraic,saveNodeCoors,PointSymbol=none,PointName=none](-1,-3.5)(6,4)
    psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
    pstInterFF{f(x)}{g(x)}{0}{A}
    pstInterFF{f(x)}{g(x)}{5}{B}
    pscustom*[linecolor=yellow!50]{%
    psplot{N-A.x}{N-B.x}{f(x)}
    psplot{N-B.x}{N-A.x}{g(x)}
    closepath
    }
    psset{linewidth=2pt,linecolor=cyan}
    psplot{.5}{5}{f(x)}
    psplot{-.5}{5}{g(x)}
    uput[-90](*5 {g(x)}){$y=-x+2$}
    uput[45](*.7 {f(x)}){$y=x^2-6x+6$}
    end{pspicture}
    end{document}


    enter image description here



    Statically hard-coded Version



    Cons: you have to calculate the intersection points in advance by hands.



    documentclass[pstricks,border=12pt]{standalone}
    usepackage{pst-plot}

    deff{x^2-6*x+6}
    defg{2-x}

    begin{document}
    begin{pspicture}[algebraic](-1,-3.5)(6,4)
    psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
    pscustom[fillstyle=vlines,hatchcolor=red,hatchsep=0.8pt]{psplot{1}{4}{f}psplot{4}{1}{g}}
    psset{linewidth=2pt,linecolor=blue}
    psplot{.5}{5}{f}
    psplot{-.5}{5}{g}
    uput[-90](*5 {g}){$y=-x+2$}
    uput[45](*.7 {f}){$y=x^2-6x+6$}
    end{pspicture}
    end{document}


    enter image description here






    share|improve this answer




























      3














      Generic Template



      Proposed features:




      • functions are defined globally so you can change easily.

      • intersection points are calculated at "runtime" as opposed to statically hard coded.




      documentclass[pstricks,border=12pt]{standalone}
      usepackage{pst-eucl,pst-plot}


      deff(#1){((#1)^2-6*(#1)+6)}
      defg(#1){(2-(#1))}

      begin{document}
      begin{pspicture}[algebraic,saveNodeCoors,PointSymbol=none,PointName=none](-1,-3.5)(6,4)
      psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
      pstInterFF{f(x)}{g(x)}{0}{A}
      pstInterFF{f(x)}{g(x)}{5}{B}
      pscustom*[linecolor=yellow!50]{%
      psplot{N-A.x}{N-B.x}{f(x)}
      psplot{N-B.x}{N-A.x}{g(x)}
      closepath
      }
      psset{linewidth=2pt,linecolor=cyan}
      psplot{.5}{5}{f(x)}
      psplot{-.5}{5}{g(x)}
      uput[-90](*5 {g(x)}){$y=-x+2$}
      uput[45](*.7 {f(x)}){$y=x^2-6x+6$}
      end{pspicture}
      end{document}


      enter image description here



      Statically hard-coded Version



      Cons: you have to calculate the intersection points in advance by hands.



      documentclass[pstricks,border=12pt]{standalone}
      usepackage{pst-plot}

      deff{x^2-6*x+6}
      defg{2-x}

      begin{document}
      begin{pspicture}[algebraic](-1,-3.5)(6,4)
      psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
      pscustom[fillstyle=vlines,hatchcolor=red,hatchsep=0.8pt]{psplot{1}{4}{f}psplot{4}{1}{g}}
      psset{linewidth=2pt,linecolor=blue}
      psplot{.5}{5}{f}
      psplot{-.5}{5}{g}
      uput[-90](*5 {g}){$y=-x+2$}
      uput[45](*.7 {f}){$y=x^2-6x+6$}
      end{pspicture}
      end{document}


      enter image description here






      share|improve this answer


























        3












        3








        3






        Generic Template



        Proposed features:




        • functions are defined globally so you can change easily.

        • intersection points are calculated at "runtime" as opposed to statically hard coded.




        documentclass[pstricks,border=12pt]{standalone}
        usepackage{pst-eucl,pst-plot}


        deff(#1){((#1)^2-6*(#1)+6)}
        defg(#1){(2-(#1))}

        begin{document}
        begin{pspicture}[algebraic,saveNodeCoors,PointSymbol=none,PointName=none](-1,-3.5)(6,4)
        psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
        pstInterFF{f(x)}{g(x)}{0}{A}
        pstInterFF{f(x)}{g(x)}{5}{B}
        pscustom*[linecolor=yellow!50]{%
        psplot{N-A.x}{N-B.x}{f(x)}
        psplot{N-B.x}{N-A.x}{g(x)}
        closepath
        }
        psset{linewidth=2pt,linecolor=cyan}
        psplot{.5}{5}{f(x)}
        psplot{-.5}{5}{g(x)}
        uput[-90](*5 {g(x)}){$y=-x+2$}
        uput[45](*.7 {f(x)}){$y=x^2-6x+6$}
        end{pspicture}
        end{document}


        enter image description here



        Statically hard-coded Version



        Cons: you have to calculate the intersection points in advance by hands.



        documentclass[pstricks,border=12pt]{standalone}
        usepackage{pst-plot}

        deff{x^2-6*x+6}
        defg{2-x}

        begin{document}
        begin{pspicture}[algebraic](-1,-3.5)(6,4)
        psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
        pscustom[fillstyle=vlines,hatchcolor=red,hatchsep=0.8pt]{psplot{1}{4}{f}psplot{4}{1}{g}}
        psset{linewidth=2pt,linecolor=blue}
        psplot{.5}{5}{f}
        psplot{-.5}{5}{g}
        uput[-90](*5 {g}){$y=-x+2$}
        uput[45](*.7 {f}){$y=x^2-6x+6$}
        end{pspicture}
        end{document}


        enter image description here






        share|improve this answer














        Generic Template



        Proposed features:




        • functions are defined globally so you can change easily.

        • intersection points are calculated at "runtime" as opposed to statically hard coded.




        documentclass[pstricks,border=12pt]{standalone}
        usepackage{pst-eucl,pst-plot}


        deff(#1){((#1)^2-6*(#1)+6)}
        defg(#1){(2-(#1))}

        begin{document}
        begin{pspicture}[algebraic,saveNodeCoors,PointSymbol=none,PointName=none](-1,-3.5)(6,4)
        psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
        pstInterFF{f(x)}{g(x)}{0}{A}
        pstInterFF{f(x)}{g(x)}{5}{B}
        pscustom*[linecolor=yellow!50]{%
        psplot{N-A.x}{N-B.x}{f(x)}
        psplot{N-B.x}{N-A.x}{g(x)}
        closepath
        }
        psset{linewidth=2pt,linecolor=cyan}
        psplot{.5}{5}{f(x)}
        psplot{-.5}{5}{g(x)}
        uput[-90](*5 {g(x)}){$y=-x+2$}
        uput[45](*.7 {f(x)}){$y=x^2-6x+6$}
        end{pspicture}
        end{document}


        enter image description here



        Statically hard-coded Version



        Cons: you have to calculate the intersection points in advance by hands.



        documentclass[pstricks,border=12pt]{standalone}
        usepackage{pst-plot}

        deff{x^2-6*x+6}
        defg{2-x}

        begin{document}
        begin{pspicture}[algebraic](-1,-3.5)(6,4)
        psaxes{->}(0,0)(-.5,-3.5)(5.5,3.5)[$x$,0][$y$,90]
        pscustom[fillstyle=vlines,hatchcolor=red,hatchsep=0.8pt]{psplot{1}{4}{f}psplot{4}{1}{g}}
        psset{linewidth=2pt,linecolor=blue}
        psplot{.5}{5}{f}
        psplot{-.5}{5}{g}
        uput[-90](*5 {g}){$y=-x+2$}
        uput[45](*.7 {f}){$y=x^2-6x+6$}
        end{pspicture}
        end{document}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 20 '18 at 9:21

























        answered Nov 20 '18 at 8:55









        God Must Be Crazy

        5,64011039




        5,64011039






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f460890%2fhow-to-raster-area-bounded-by-two-functions%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

            "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

            Alcedinidae

            RAC Tourist Trophy