How to raster area bounded by two functions?











up vote
4
down vote

favorite












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 at 8:30










  • Thank you for your remind.
    – Trong Vuong
    Nov 20 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 at 9:22










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








  • 1




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















up vote
4
down vote

favorite












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 at 8:30










  • Thank you for your remind.
    – Trong Vuong
    Nov 20 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 at 9:22










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








  • 1




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













up vote
4
down vote

favorite









up vote
4
down vote

favorite











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 4 mins ago

























asked Nov 20 at 8:19









Trong Vuong

2039




2039








  • 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 at 8:30










  • Thank you for your remind.
    – Trong Vuong
    Nov 20 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 at 9:22










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








  • 1




    linestyle=curve should be plotstyle=curve
    – Herbert
    Nov 20 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 at 8:30










  • Thank you for your remind.
    – Trong Vuong
    Nov 20 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 at 9:22










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








  • 1




    linestyle=curve should be plotstyle=curve
    – Herbert
    Nov 20 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 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 at 8:30












Thank you for your remind.
– Trong Vuong
Nov 20 at 8:40




Thank you for your remind.
– Trong Vuong
Nov 20 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 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 at 9:22












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






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






1




1




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




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










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










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.
    – Trong Vuong
    Nov 20 at 9:23


















up vote
2
down vote













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























  • :((, Sadly, a long answer.
    – Trong Vuong
    Nov 20 at 8:57










  • Anyhow, big thanks. However, can you edit the above code? :-)). I am not enough knowledge to write the code like YOU! :))
    – Trong Vuong
    Nov 20 at 9:03












  • Your anwser is very good but I will vote Herbert's anwser. Sympathize for me( gg translate) :-))
    – Trong Vuong
    Nov 20 at 9:26










  • I have just updated my question, if you know about it , please reply to me. thanks
    – Trong Vuong
    20 mins ago










  • @TrongVuong: You should create a new question for this kind of problem.
    – Artificial Stupidity
    10 mins ago











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',
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








up vote
3
down vote



accepted










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.
    – Trong Vuong
    Nov 20 at 9:23















up vote
3
down vote



accepted










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.
    – Trong Vuong
    Nov 20 at 9:23













up vote
3
down vote



accepted







up vote
3
down vote



accepted






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 at 9:41

























answered Nov 20 at 9:05









Herbert

265k23403712




265k23403712












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


















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
















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




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










up vote
2
down vote













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























  • :((, Sadly, a long answer.
    – Trong Vuong
    Nov 20 at 8:57










  • Anyhow, big thanks. However, can you edit the above code? :-)). I am not enough knowledge to write the code like YOU! :))
    – Trong Vuong
    Nov 20 at 9:03












  • Your anwser is very good but I will vote Herbert's anwser. Sympathize for me( gg translate) :-))
    – Trong Vuong
    Nov 20 at 9:26










  • I have just updated my question, if you know about it , please reply to me. thanks
    – Trong Vuong
    20 mins ago










  • @TrongVuong: You should create a new question for this kind of problem.
    – Artificial Stupidity
    10 mins ago















up vote
2
down vote













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























  • :((, Sadly, a long answer.
    – Trong Vuong
    Nov 20 at 8:57










  • Anyhow, big thanks. However, can you edit the above code? :-)). I am not enough knowledge to write the code like YOU! :))
    – Trong Vuong
    Nov 20 at 9:03












  • Your anwser is very good but I will vote Herbert's anwser. Sympathize for me( gg translate) :-))
    – Trong Vuong
    Nov 20 at 9:26










  • I have just updated my question, if you know about it , please reply to me. thanks
    – Trong Vuong
    20 mins ago










  • @TrongVuong: You should create a new question for this kind of problem.
    – Artificial Stupidity
    10 mins ago













up vote
2
down vote










up vote
2
down vote









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 at 9:21

























answered Nov 20 at 8:55









Artificial Stupidity

4,6641832




4,6641832












  • :((, Sadly, a long answer.
    – Trong Vuong
    Nov 20 at 8:57










  • Anyhow, big thanks. However, can you edit the above code? :-)). I am not enough knowledge to write the code like YOU! :))
    – Trong Vuong
    Nov 20 at 9:03












  • Your anwser is very good but I will vote Herbert's anwser. Sympathize for me( gg translate) :-))
    – Trong Vuong
    Nov 20 at 9:26










  • I have just updated my question, if you know about it , please reply to me. thanks
    – Trong Vuong
    20 mins ago










  • @TrongVuong: You should create a new question for this kind of problem.
    – Artificial Stupidity
    10 mins ago


















  • :((, Sadly, a long answer.
    – Trong Vuong
    Nov 20 at 8:57










  • Anyhow, big thanks. However, can you edit the above code? :-)). I am not enough knowledge to write the code like YOU! :))
    – Trong Vuong
    Nov 20 at 9:03












  • Your anwser is very good but I will vote Herbert's anwser. Sympathize for me( gg translate) :-))
    – Trong Vuong
    Nov 20 at 9:26










  • I have just updated my question, if you know about it , please reply to me. thanks
    – Trong Vuong
    20 mins ago










  • @TrongVuong: You should create a new question for this kind of problem.
    – Artificial Stupidity
    10 mins ago
















:((, Sadly, a long answer.
– Trong Vuong
Nov 20 at 8:57




:((, Sadly, a long answer.
– Trong Vuong
Nov 20 at 8:57












Anyhow, big thanks. However, can you edit the above code? :-)). I am not enough knowledge to write the code like YOU! :))
– Trong Vuong
Nov 20 at 9:03






Anyhow, big thanks. However, can you edit the above code? :-)). I am not enough knowledge to write the code like YOU! :))
– Trong Vuong
Nov 20 at 9:03














Your anwser is very good but I will vote Herbert's anwser. Sympathize for me( gg translate) :-))
– Trong Vuong
Nov 20 at 9:26




Your anwser is very good but I will vote Herbert's anwser. Sympathize for me( gg translate) :-))
– Trong Vuong
Nov 20 at 9:26












I have just updated my question, if you know about it , please reply to me. thanks
– Trong Vuong
20 mins ago




I have just updated my question, if you know about it , please reply to me. thanks
– Trong Vuong
20 mins ago












@TrongVuong: You should create a new question for this kind of problem.
– Artificial Stupidity
10 mins ago




@TrongVuong: You should create a new question for this kind of problem.
– Artificial Stupidity
10 mins ago


















 

draft saved


draft discarded



















































 


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

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks