I want to color a graphTikZ: draw line thickness less than 0.1 mmLaTeX equivalent of ConTeXt buffersVisualize...

Do my Windows system binaries contain sensitive information?

What's the rationale behind the objections to these measures against human trafficking?

Quenching swords in dragon blood; why?

Proof by Induction - New to proofs

Why zero tolerance on nudity in space?

Is Draco canonically good-looking?

Could quantum mechanics be necessary to analyze some biology scenarios?

Criticizing long fiction. How is it different from short?

Has the Isbell–Freyd criterion ever been used to check that a category is concretisable?

What is Crew Dragon approaching in this picture?

A Wacky, Wacky Chessboard (That Makes No Sense)

Do commercial flights continue with an engine out?

Is my plan for fixing my water heater leak bad?

Can chords be played on the flute?

Can the Count of Monte Cristo's calculation of poison dosage be explained?

Is the theory of the category of topological spaces computable?

How to use a mathematical expression as xticklable

How would one communicate with the hive mind of the human race?

Meth dealer reference in Family Guy

What can I substitute for soda pop in a sweet pork recipe?

How to define a macro with multiple optional parameters?

On what did Lego base the appearance of the new Hogwarts minifigs?

Do authors have to be politically correct in article-writing?

raspberry pi change directory (cd) command not working with USB drive



I want to color a graph


TikZ: draw line thickness less than 0.1 mmLaTeX equivalent of ConTeXt buffersVisualize data on a variable-radius graph/networkColor the faces of a graphTikZ scaling graphic and adjust node position and keep font sizeGraph functions & color area under curvesLine up nested tikz enviroments or how to get rid of themProblems with nested TikZpicturesHighlighting and Labeling specific nodes in scatter plotThe TikZ pipeline: A path's 'draw' option has no effect on a 'behind path' nodeDrawing an imperfect spiral in TikZ













2















enter image description here



Im very new to making latex so all the tutorials I have found about my question were too hard to understand or didn't do exactly what I wanted.



I already have the graph I want without the coloring:



begin{figure}
centering
begin{tikzpicture}
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});

end{tikzpicture}
end{figure}









share|improve this question







New contributor




Hans is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    (written without compiling) fill [green] (-2,0) plot [domain=0:1.26] (x,x^3) |- cycle;

    – Symbol 1
    Feb 27 at 15:53













  • Oh i didnt know it was that easy! It looks good, but because of the scale=0.4, the green area isnt correctly under the graph. How to i re-scale the green area?

    – Hans
    Feb 27 at 16:10











  • I figured it out! i just added it in the square brackets: fill [green, scale=0.4] (-2,2) plot [domain=0:0.5] (x,x^3) |- cycle;

    – Hans
    Feb 27 at 16:12













  • But how do I color even farther out to the right like I drew on the paper? And how to color the other four areas?

    – Hans
    Feb 27 at 16:21











  • Either you specify coordinates carefully (e.g. 1.26 in my code in cubic root of 2) or use clip

    – Symbol 1
    Feb 27 at 16:23


















2















enter image description here



Im very new to making latex so all the tutorials I have found about my question were too hard to understand or didn't do exactly what I wanted.



I already have the graph I want without the coloring:



begin{figure}
centering
begin{tikzpicture}
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});

end{tikzpicture}
end{figure}









share|improve this question







New contributor




Hans is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    (written without compiling) fill [green] (-2,0) plot [domain=0:1.26] (x,x^3) |- cycle;

    – Symbol 1
    Feb 27 at 15:53













  • Oh i didnt know it was that easy! It looks good, but because of the scale=0.4, the green area isnt correctly under the graph. How to i re-scale the green area?

    – Hans
    Feb 27 at 16:10











  • I figured it out! i just added it in the square brackets: fill [green, scale=0.4] (-2,2) plot [domain=0:0.5] (x,x^3) |- cycle;

    – Hans
    Feb 27 at 16:12













  • But how do I color even farther out to the right like I drew on the paper? And how to color the other four areas?

    – Hans
    Feb 27 at 16:21











  • Either you specify coordinates carefully (e.g. 1.26 in my code in cubic root of 2) or use clip

    – Symbol 1
    Feb 27 at 16:23
















2












2








2


2






enter image description here



Im very new to making latex so all the tutorials I have found about my question were too hard to understand or didn't do exactly what I wanted.



I already have the graph I want without the coloring:



begin{figure}
centering
begin{tikzpicture}
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});

end{tikzpicture}
end{figure}









share|improve this question







New contributor




Hans is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












enter image description here



Im very new to making latex so all the tutorials I have found about my question were too hard to understand or didn't do exactly what I wanted.



I already have the graph I want without the coloring:



begin{figure}
centering
begin{tikzpicture}
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});

end{tikzpicture}
end{figure}






tikz-pgf






share|improve this question







New contributor




Hans is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Hans is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Hans is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Feb 27 at 15:50









HansHans

132




132




New contributor




Hans is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Hans is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Hans is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1





    (written without compiling) fill [green] (-2,0) plot [domain=0:1.26] (x,x^3) |- cycle;

    – Symbol 1
    Feb 27 at 15:53













  • Oh i didnt know it was that easy! It looks good, but because of the scale=0.4, the green area isnt correctly under the graph. How to i re-scale the green area?

    – Hans
    Feb 27 at 16:10











  • I figured it out! i just added it in the square brackets: fill [green, scale=0.4] (-2,2) plot [domain=0:0.5] (x,x^3) |- cycle;

    – Hans
    Feb 27 at 16:12













  • But how do I color even farther out to the right like I drew on the paper? And how to color the other four areas?

    – Hans
    Feb 27 at 16:21











  • Either you specify coordinates carefully (e.g. 1.26 in my code in cubic root of 2) or use clip

    – Symbol 1
    Feb 27 at 16:23
















  • 1





    (written without compiling) fill [green] (-2,0) plot [domain=0:1.26] (x,x^3) |- cycle;

    – Symbol 1
    Feb 27 at 15:53













  • Oh i didnt know it was that easy! It looks good, but because of the scale=0.4, the green area isnt correctly under the graph. How to i re-scale the green area?

    – Hans
    Feb 27 at 16:10











  • I figured it out! i just added it in the square brackets: fill [green, scale=0.4] (-2,2) plot [domain=0:0.5] (x,x^3) |- cycle;

    – Hans
    Feb 27 at 16:12













  • But how do I color even farther out to the right like I drew on the paper? And how to color the other four areas?

    – Hans
    Feb 27 at 16:21











  • Either you specify coordinates carefully (e.g. 1.26 in my code in cubic root of 2) or use clip

    – Symbol 1
    Feb 27 at 16:23










1




1





(written without compiling) fill [green] (-2,0) plot [domain=0:1.26] (x,x^3) |- cycle;

– Symbol 1
Feb 27 at 15:53







(written without compiling) fill [green] (-2,0) plot [domain=0:1.26] (x,x^3) |- cycle;

– Symbol 1
Feb 27 at 15:53















Oh i didnt know it was that easy! It looks good, but because of the scale=0.4, the green area isnt correctly under the graph. How to i re-scale the green area?

– Hans
Feb 27 at 16:10





Oh i didnt know it was that easy! It looks good, but because of the scale=0.4, the green area isnt correctly under the graph. How to i re-scale the green area?

– Hans
Feb 27 at 16:10













I figured it out! i just added it in the square brackets: fill [green, scale=0.4] (-2,2) plot [domain=0:0.5] (x,x^3) |- cycle;

– Hans
Feb 27 at 16:12







I figured it out! i just added it in the square brackets: fill [green, scale=0.4] (-2,2) plot [domain=0:0.5] (x,x^3) |- cycle;

– Hans
Feb 27 at 16:12















But how do I color even farther out to the right like I drew on the paper? And how to color the other four areas?

– Hans
Feb 27 at 16:21





But how do I color even farther out to the right like I drew on the paper? And how to color the other four areas?

– Hans
Feb 27 at 16:21













Either you specify coordinates carefully (e.g. 1.26 in my code in cubic root of 2) or use clip

– Symbol 1
Feb 27 at 16:23







Either you specify coordinates carefully (e.g. 1.26 in my code in cubic root of 2) or use clip

– Symbol 1
Feb 27 at 16:23












3 Answers
3






active

oldest

votes


















5














Here is my suggestion, without slightly line, because the filling is made differently (code modified from AndréC answer):



documentclass[tikz,border=5mm]{standalone}
begin{document}
begin{tikzpicture}

begin{scope}
clip[postaction={fill=green!50}] (-2,-2) rectangle (2,2);
fill[scale=0.4,domain=0:5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
fill[scale=0.4,domain=0:-5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
end{scope}

draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


(Code edited with marmot's useful suggestion: using postaction to reduce redundant code.)



enter image description here






share|improve this answer





















  • 1





    @marmot Thanks, I have edited with your great advice.

    – quark67
    Feb 27 at 22:50



















3














A tricky way:



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


enter image description here



Edit:



A tricky way needs to be continued by a tricky addition. I added a line width=0mm line (see here):



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[line width=0mm,green!50] ({1.71*0.4},{0.4*(1.71^3)})--({-1.71*0.4},{0.4*(-1.71^3)}); % <===================
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


The very thin line has gone I think.



enter image description here






share|improve this answer


























  • We see a line that joins the two ends of the curve.

    – AndréC
    Feb 27 at 17:00











  • That looks exactly like i want it! But is there any way to get around that slightly visible dark-green line that goes from (1.71*0.4, 0.4*(1.71^3)) to (-1.71*0.4,0.4*(-1.71^3))?

    – Hans
    Feb 27 at 17:01













  • @Hans See my answer, I have removed the slight line with a different filling technique.

    – quark67
    Feb 27 at 21:37











  • @Hans I have edited my answer. (I'm sorry for being late).

    – JouleV
    Feb 28 at 4:08













  • By the way, as my solution is not standard, it doesn't deserve a tick. Accept quark67's answer instead.

    – JouleV
    Feb 28 at 4:11



















2














With pgfplots, this is easy to do.



Here is a pure tikz DIY without a single piece of pgfplots!



documentclass[tikz,border=5mm]{standalone}

begin{document}

begin{tikzpicture}
fill[blue!20] (-2,-2)rectangle(2,2);
begin{scope}[transparency group,opacity=1]
fill[scale=0.4,domain=0:1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(a)|-(0,0)node[midway](m){};
fill[green](a)--(2,2)|-(m.west);
fill[scale=0.4,domain=0:-1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(b)|-(0,0)node[midway](n){};
fill[green](b)--(-2,-2)|-(n.east);
end{scope}
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


screenshot






share|improve this answer


























  • There is a slight vertical line in your screenshot (at x=-1.71) because you fill this lower left domain with 2 areas (there is also a slight vertical line at x=+1.71 in the upper right domain, but not visible in your screenshot).

    – quark67
    Feb 27 at 21:22











  • You have a much better view than I do. I have just created a transparency group, normally this little net should have disappeared.

    – AndréC
    Feb 27 at 22:19













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
});


}
});






Hans is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476980%2fi-want-to-color-a-graph%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









5














Here is my suggestion, without slightly line, because the filling is made differently (code modified from AndréC answer):



documentclass[tikz,border=5mm]{standalone}
begin{document}
begin{tikzpicture}

begin{scope}
clip[postaction={fill=green!50}] (-2,-2) rectangle (2,2);
fill[scale=0.4,domain=0:5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
fill[scale=0.4,domain=0:-5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
end{scope}

draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


(Code edited with marmot's useful suggestion: using postaction to reduce redundant code.)



enter image description here






share|improve this answer





















  • 1





    @marmot Thanks, I have edited with your great advice.

    – quark67
    Feb 27 at 22:50
















5














Here is my suggestion, without slightly line, because the filling is made differently (code modified from AndréC answer):



documentclass[tikz,border=5mm]{standalone}
begin{document}
begin{tikzpicture}

begin{scope}
clip[postaction={fill=green!50}] (-2,-2) rectangle (2,2);
fill[scale=0.4,domain=0:5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
fill[scale=0.4,domain=0:-5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
end{scope}

draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


(Code edited with marmot's useful suggestion: using postaction to reduce redundant code.)



enter image description here






share|improve this answer





















  • 1





    @marmot Thanks, I have edited with your great advice.

    – quark67
    Feb 27 at 22:50














5












5








5







Here is my suggestion, without slightly line, because the filling is made differently (code modified from AndréC answer):



documentclass[tikz,border=5mm]{standalone}
begin{document}
begin{tikzpicture}

begin{scope}
clip[postaction={fill=green!50}] (-2,-2) rectangle (2,2);
fill[scale=0.4,domain=0:5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
fill[scale=0.4,domain=0:-5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
end{scope}

draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


(Code edited with marmot's useful suggestion: using postaction to reduce redundant code.)



enter image description here






share|improve this answer















Here is my suggestion, without slightly line, because the filling is made differently (code modified from AndréC answer):



documentclass[tikz,border=5mm]{standalone}
begin{document}
begin{tikzpicture}

begin{scope}
clip[postaction={fill=green!50}] (-2,-2) rectangle (2,2);
fill[scale=0.4,domain=0:5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
fill[scale=0.4,domain=0:-5,smooth,variable=x,blue!20] plot ({x},{(x)^3}) |-(0,0);
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
end{scope}

draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


(Code edited with marmot's useful suggestion: using postaction to reduce redundant code.)



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 27 at 22:49

























answered Feb 27 at 21:30









quark67quark67

19415




19415








  • 1





    @marmot Thanks, I have edited with your great advice.

    – quark67
    Feb 27 at 22:50














  • 1





    @marmot Thanks, I have edited with your great advice.

    – quark67
    Feb 27 at 22:50








1




1





@marmot Thanks, I have edited with your great advice.

– quark67
Feb 27 at 22:50





@marmot Thanks, I have edited with your great advice.

– quark67
Feb 27 at 22:50











3














A tricky way:



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


enter image description here



Edit:



A tricky way needs to be continued by a tricky addition. I added a line width=0mm line (see here):



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[line width=0mm,green!50] ({1.71*0.4},{0.4*(1.71^3)})--({-1.71*0.4},{0.4*(-1.71^3)}); % <===================
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


The very thin line has gone I think.



enter image description here






share|improve this answer


























  • We see a line that joins the two ends of the curve.

    – AndréC
    Feb 27 at 17:00











  • That looks exactly like i want it! But is there any way to get around that slightly visible dark-green line that goes from (1.71*0.4, 0.4*(1.71^3)) to (-1.71*0.4,0.4*(-1.71^3))?

    – Hans
    Feb 27 at 17:01













  • @Hans See my answer, I have removed the slight line with a different filling technique.

    – quark67
    Feb 27 at 21:37











  • @Hans I have edited my answer. (I'm sorry for being late).

    – JouleV
    Feb 28 at 4:08













  • By the way, as my solution is not standard, it doesn't deserve a tick. Accept quark67's answer instead.

    – JouleV
    Feb 28 at 4:11
















3














A tricky way:



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


enter image description here



Edit:



A tricky way needs to be continued by a tricky addition. I added a line width=0mm line (see here):



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[line width=0mm,green!50] ({1.71*0.4},{0.4*(1.71^3)})--({-1.71*0.4},{0.4*(-1.71^3)}); % <===================
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


The very thin line has gone I think.



enter image description here






share|improve this answer


























  • We see a line that joins the two ends of the curve.

    – AndréC
    Feb 27 at 17:00











  • That looks exactly like i want it! But is there any way to get around that slightly visible dark-green line that goes from (1.71*0.4, 0.4*(1.71^3)) to (-1.71*0.4,0.4*(-1.71^3))?

    – Hans
    Feb 27 at 17:01













  • @Hans See my answer, I have removed the slight line with a different filling technique.

    – quark67
    Feb 27 at 21:37











  • @Hans I have edited my answer. (I'm sorry for being late).

    – JouleV
    Feb 28 at 4:08













  • By the way, as my solution is not standard, it doesn't deserve a tick. Accept quark67's answer instead.

    – JouleV
    Feb 28 at 4:11














3












3








3







A tricky way:



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


enter image description here



Edit:



A tricky way needs to be continued by a tricky addition. I added a line width=0mm line (see here):



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[line width=0mm,green!50] ({1.71*0.4},{0.4*(1.71^3)})--({-1.71*0.4},{0.4*(-1.71^3)}); % <===================
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


The very thin line has gone I think.



enter image description here






share|improve this answer















A tricky way:



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


enter image description here



Edit:



A tricky way needs to be continued by a tricky addition. I added a line width=0mm line (see here):



documentclass[tikz,margin=3mm]{standalone}
begin{document}
begin{tikzpicture}
fill[blue!20] (-2,-2) rectangle (2,2);
fill[green!50] (0,0)--({-1.71*0.4},{0.4*(-1.71^3)})--(2,-2)--(2,0)--cycle;
fill[green!50] (0,0)--({1.71*0.4},{0.4*(1.71^3)})--(-2,2)--(-2,0)--cycle;
draw[line width=0mm,green!50] ({1.71*0.4},{0.4*(1.71^3)})--({-1.71*0.4},{0.4*(-1.71^3)}); % <===================
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black,fill=green!50] plot ({x},{(x)^3});
end{tikzpicture}
end{document}


The very thin line has gone I think.



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 28 at 4:08

























answered Feb 27 at 16:27









JouleVJouleV

4,6861939




4,6861939













  • We see a line that joins the two ends of the curve.

    – AndréC
    Feb 27 at 17:00











  • That looks exactly like i want it! But is there any way to get around that slightly visible dark-green line that goes from (1.71*0.4, 0.4*(1.71^3)) to (-1.71*0.4,0.4*(-1.71^3))?

    – Hans
    Feb 27 at 17:01













  • @Hans See my answer, I have removed the slight line with a different filling technique.

    – quark67
    Feb 27 at 21:37











  • @Hans I have edited my answer. (I'm sorry for being late).

    – JouleV
    Feb 28 at 4:08













  • By the way, as my solution is not standard, it doesn't deserve a tick. Accept quark67's answer instead.

    – JouleV
    Feb 28 at 4:11



















  • We see a line that joins the two ends of the curve.

    – AndréC
    Feb 27 at 17:00











  • That looks exactly like i want it! But is there any way to get around that slightly visible dark-green line that goes from (1.71*0.4, 0.4*(1.71^3)) to (-1.71*0.4,0.4*(-1.71^3))?

    – Hans
    Feb 27 at 17:01













  • @Hans See my answer, I have removed the slight line with a different filling technique.

    – quark67
    Feb 27 at 21:37











  • @Hans I have edited my answer. (I'm sorry for being late).

    – JouleV
    Feb 28 at 4:08













  • By the way, as my solution is not standard, it doesn't deserve a tick. Accept quark67's answer instead.

    – JouleV
    Feb 28 at 4:11

















We see a line that joins the two ends of the curve.

– AndréC
Feb 27 at 17:00





We see a line that joins the two ends of the curve.

– AndréC
Feb 27 at 17:00













That looks exactly like i want it! But is there any way to get around that slightly visible dark-green line that goes from (1.71*0.4, 0.4*(1.71^3)) to (-1.71*0.4,0.4*(-1.71^3))?

– Hans
Feb 27 at 17:01







That looks exactly like i want it! But is there any way to get around that slightly visible dark-green line that goes from (1.71*0.4, 0.4*(1.71^3)) to (-1.71*0.4,0.4*(-1.71^3))?

– Hans
Feb 27 at 17:01















@Hans See my answer, I have removed the slight line with a different filling technique.

– quark67
Feb 27 at 21:37





@Hans See my answer, I have removed the slight line with a different filling technique.

– quark67
Feb 27 at 21:37













@Hans I have edited my answer. (I'm sorry for being late).

– JouleV
Feb 28 at 4:08







@Hans I have edited my answer. (I'm sorry for being late).

– JouleV
Feb 28 at 4:08















By the way, as my solution is not standard, it doesn't deserve a tick. Accept quark67's answer instead.

– JouleV
Feb 28 at 4:11





By the way, as my solution is not standard, it doesn't deserve a tick. Accept quark67's answer instead.

– JouleV
Feb 28 at 4:11











2














With pgfplots, this is easy to do.



Here is a pure tikz DIY without a single piece of pgfplots!



documentclass[tikz,border=5mm]{standalone}

begin{document}

begin{tikzpicture}
fill[blue!20] (-2,-2)rectangle(2,2);
begin{scope}[transparency group,opacity=1]
fill[scale=0.4,domain=0:1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(a)|-(0,0)node[midway](m){};
fill[green](a)--(2,2)|-(m.west);
fill[scale=0.4,domain=0:-1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(b)|-(0,0)node[midway](n){};
fill[green](b)--(-2,-2)|-(n.east);
end{scope}
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


screenshot






share|improve this answer


























  • There is a slight vertical line in your screenshot (at x=-1.71) because you fill this lower left domain with 2 areas (there is also a slight vertical line at x=+1.71 in the upper right domain, but not visible in your screenshot).

    – quark67
    Feb 27 at 21:22











  • You have a much better view than I do. I have just created a transparency group, normally this little net should have disappeared.

    – AndréC
    Feb 27 at 22:19


















2














With pgfplots, this is easy to do.



Here is a pure tikz DIY without a single piece of pgfplots!



documentclass[tikz,border=5mm]{standalone}

begin{document}

begin{tikzpicture}
fill[blue!20] (-2,-2)rectangle(2,2);
begin{scope}[transparency group,opacity=1]
fill[scale=0.4,domain=0:1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(a)|-(0,0)node[midway](m){};
fill[green](a)--(2,2)|-(m.west);
fill[scale=0.4,domain=0:-1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(b)|-(0,0)node[midway](n){};
fill[green](b)--(-2,-2)|-(n.east);
end{scope}
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


screenshot






share|improve this answer


























  • There is a slight vertical line in your screenshot (at x=-1.71) because you fill this lower left domain with 2 areas (there is also a slight vertical line at x=+1.71 in the upper right domain, but not visible in your screenshot).

    – quark67
    Feb 27 at 21:22











  • You have a much better view than I do. I have just created a transparency group, normally this little net should have disappeared.

    – AndréC
    Feb 27 at 22:19
















2












2








2







With pgfplots, this is easy to do.



Here is a pure tikz DIY without a single piece of pgfplots!



documentclass[tikz,border=5mm]{standalone}

begin{document}

begin{tikzpicture}
fill[blue!20] (-2,-2)rectangle(2,2);
begin{scope}[transparency group,opacity=1]
fill[scale=0.4,domain=0:1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(a)|-(0,0)node[midway](m){};
fill[green](a)--(2,2)|-(m.west);
fill[scale=0.4,domain=0:-1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(b)|-(0,0)node[midway](n){};
fill[green](b)--(-2,-2)|-(n.east);
end{scope}
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


screenshot






share|improve this answer















With pgfplots, this is easy to do.



Here is a pure tikz DIY without a single piece of pgfplots!



documentclass[tikz,border=5mm]{standalone}

begin{document}

begin{tikzpicture}
fill[blue!20] (-2,-2)rectangle(2,2);
begin{scope}[transparency group,opacity=1]
fill[scale=0.4,domain=0:1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(a)|-(0,0)node[midway](m){};
fill[green](a)--(2,2)|-(m.west);
fill[scale=0.4,domain=0:-1.71,smooth,variable=x,green] plot ({x},{(x)^3})coordinate(b)|-(0,0)node[midway](n){};
fill[green](b)--(-2,-2)|-(n.east);
end{scope}
draw[scale=0.4,domain=-1.71:1.71,smooth,variable=x,black] plot ({x},{(x)^3});
draw[->] (-2,0) -- (2,0) node[right] {$x$};
draw[->] (0,-2) -- (0,2) node[above] {$y$};
end{tikzpicture}
end{document}


screenshot







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 28 at 6:02

























answered Feb 27 at 17:55









AndréCAndréC

9,52311547




9,52311547













  • There is a slight vertical line in your screenshot (at x=-1.71) because you fill this lower left domain with 2 areas (there is also a slight vertical line at x=+1.71 in the upper right domain, but not visible in your screenshot).

    – quark67
    Feb 27 at 21:22











  • You have a much better view than I do. I have just created a transparency group, normally this little net should have disappeared.

    – AndréC
    Feb 27 at 22:19





















  • There is a slight vertical line in your screenshot (at x=-1.71) because you fill this lower left domain with 2 areas (there is also a slight vertical line at x=+1.71 in the upper right domain, but not visible in your screenshot).

    – quark67
    Feb 27 at 21:22











  • You have a much better view than I do. I have just created a transparency group, normally this little net should have disappeared.

    – AndréC
    Feb 27 at 22:19



















There is a slight vertical line in your screenshot (at x=-1.71) because you fill this lower left domain with 2 areas (there is also a slight vertical line at x=+1.71 in the upper right domain, but not visible in your screenshot).

– quark67
Feb 27 at 21:22





There is a slight vertical line in your screenshot (at x=-1.71) because you fill this lower left domain with 2 areas (there is also a slight vertical line at x=+1.71 in the upper right domain, but not visible in your screenshot).

– quark67
Feb 27 at 21:22













You have a much better view than I do. I have just created a transparency group, normally this little net should have disappeared.

– AndréC
Feb 27 at 22:19







You have a much better view than I do. I have just created a transparency group, normally this little net should have disappeared.

– AndréC
Feb 27 at 22:19












Hans is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Hans is a new contributor. Be nice, and check out our Code of Conduct.













Hans is a new contributor. Be nice, and check out our Code of Conduct.












Hans is a new contributor. Be nice, and check out our Code of Conduct.
















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%2f476980%2fi-want-to-color-a-graph%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

El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

Puerta de Hutt Referencias Enlaces externos Menú de navegación15°58′00″S 5°42′00″O /...

Castillo d'Acher Características Menú de navegación