Fill area under curve using colourmap and TikzHow to fill area under plot using a color map?Filling area between curve and circle using TikZPgfplots: how to fill bounded area under a curve using addplot and fill?Tikz-picture - Fill areaTikz - Fill circle/sinus areaFillbetween doesn't fill entire area under graphFill area under a smooth curveShading area under curve TikZRiemann Sum approaches Area under Curvehow to fill the area under a curve
How do I find out when a node was added to an availability group?
Plain language with long required phrases
What mechanic is there to disable a threat instead of killing it?
What killed these X2 caps?
Can I use a neutral wire from another outlet to repair a broken neutral?
How much of data wrangling is a data scientist's job?
How do I write bicross product symbols in latex?
Is it canonical bit space?
Why are electrically insulating heatsinks so rare? Is it just cost?
What is the word for reserving something for yourself before others do?
What is the intuition behind short exact sequences of groups; in particular, what is the intuition behind group extensions?
Withdrawals from HSA
Alternative to sending password over mail?
Twin primes whose sum is a cube
How can saying a song's name be a copyright violation?
Can a virus destroy the BIOS of a modern computer?
What exploit are these user agents trying to use?
I'm flying to France today and my passport expires in less than 2 months
Etiquette around loan refinance - decision is going to cost first broker a lot of money
Infinite Abelian subgroup of infinite non Abelian group example
How to model explosives?
What does it mean to describe someone as a butt steak?
Could gravitational lensing be used to protect a spaceship from a laser?
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
Fill area under curve using colourmap and Tikz
How to fill area under plot using a color map?Filling area between curve and circle using TikZPgfplots: how to fill bounded area under a curve using addplot and fill?Tikz-picture - Fill areaTikz - Fill circle/sinus areaFillbetween doesn't fill entire area under graphFill area under a smooth curveShading area under curve TikZRiemann Sum approaches Area under Curvehow to fill the area under a curve
I'd like to use a colourmap like hot2 in this plot, where red occurs at x=0, and green occurs at x=1, but I can't find any way of doing it.
Here's what I have so far:
begintikzpicture
beginaxis[
axis lines=left,
grid=major,
no marks,
xmin=0, xmax=1, xlabel=$E$,
ymin=0, ymax=1, ylabel=$lambda$, ylabel style=rotate=-90
]
addplot+[smooth,blue,name path=A] 1 - (1 - x)^2; % actual curve
addplot+[draw=none,name path=B] 0; % “fictional” curve
addplot+[green] fill between[of=A and B,soft clip=domain=0:1]; % filling
endaxis
endtikzpicture

tikz-pgf graphics tikz-styles
New contributor
Jordan Mackie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I'd like to use a colourmap like hot2 in this plot, where red occurs at x=0, and green occurs at x=1, but I can't find any way of doing it.
Here's what I have so far:
begintikzpicture
beginaxis[
axis lines=left,
grid=major,
no marks,
xmin=0, xmax=1, xlabel=$E$,
ymin=0, ymax=1, ylabel=$lambda$, ylabel style=rotate=-90
]
addplot+[smooth,blue,name path=A] 1 - (1 - x)^2; % actual curve
addplot+[draw=none,name path=B] 0; % “fictional” curve
addplot+[green] fill between[of=A and B,soft clip=domain=0:1]; % filling
endaxis
endtikzpicture

tikz-pgf graphics tikz-styles
New contributor
Jordan Mackie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I'd like to use a colourmap like hot2 in this plot, where red occurs at x=0, and green occurs at x=1, but I can't find any way of doing it.
Here's what I have so far:
begintikzpicture
beginaxis[
axis lines=left,
grid=major,
no marks,
xmin=0, xmax=1, xlabel=$E$,
ymin=0, ymax=1, ylabel=$lambda$, ylabel style=rotate=-90
]
addplot+[smooth,blue,name path=A] 1 - (1 - x)^2; % actual curve
addplot+[draw=none,name path=B] 0; % “fictional” curve
addplot+[green] fill between[of=A and B,soft clip=domain=0:1]; % filling
endaxis
endtikzpicture

tikz-pgf graphics tikz-styles
New contributor
Jordan Mackie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I'd like to use a colourmap like hot2 in this plot, where red occurs at x=0, and green occurs at x=1, but I can't find any way of doing it.
Here's what I have so far:
begintikzpicture
beginaxis[
axis lines=left,
grid=major,
no marks,
xmin=0, xmax=1, xlabel=$E$,
ymin=0, ymax=1, ylabel=$lambda$, ylabel style=rotate=-90
]
addplot+[smooth,blue,name path=A] 1 - (1 - x)^2; % actual curve
addplot+[draw=none,name path=B] 0; % “fictional” curve
addplot+[green] fill between[of=A and B,soft clip=domain=0:1]; % filling
endaxis
endtikzpicture

tikz-pgf graphics tikz-styles
tikz-pgf graphics tikz-styles
New contributor
Jordan Mackie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Jordan Mackie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Jordan Mackie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 4 hours ago
Jordan MackieJordan Mackie
1084
1084
New contributor
Jordan Mackie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Jordan Mackie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Jordan Mackie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Welcome to TeX-SE! We usually begin our examples with documentclass, end them with enddocument and do not put non-standard characters in the code that prevents others from copying it. The following is an example of an MWE.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
newsaveboxbackbox
pgfplotscolormaptoshadingspechot7cmresult
deftempbpgfdeclarehorizontalshadingtempshading7cm%
% where 'result' is inserted as last argument:
expandaftertempbexpandafterresult%
sboxbackboxpgfuseshadingtempshading%
begindocument
begintikzpicture
beginaxis[set layers,view=900,
axis lines=left,
grid=major,
no marks,
xmin=0, xmax=1, xlabel=$E$,
ymin=0, ymax=1, ylabel=$lambda$, ylabel style=rotate=-90
]
addplot+[smooth,blue] 1 - (1 - x)^2; % actual curve
beginpgfonlayerpre main
clip plot[variable=x,samples=25,domain=0:1] (x,1 - (1 - x)^2)
|-cycle;
node at (0.5,0.5)useboxbackbox;
endpgfonlayer
% filling
endaxis
endtikzpicture
enddocument

Perfect thank you!
– Jordan Mackie
3 hours ago
It works , but I do get an error:! Undefined control sequence. <argument> backbox l.41 sboxbackboxpgfuseshadingtempshading % ?
– Jordan Mackie
3 hours ago
@JordanMackie Sorry, these statements seem to contradict each other: "it works" and "I get an error". I get this very output from runningpdflatexon the above code, of course without error message.
– marmot
2 hours ago
add a comment |
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
);
);
Jordan Mackie is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483209%2ffill-area-under-curve-using-colourmap-and-tikz%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Welcome to TeX-SE! We usually begin our examples with documentclass, end them with enddocument and do not put non-standard characters in the code that prevents others from copying it. The following is an example of an MWE.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
newsaveboxbackbox
pgfplotscolormaptoshadingspechot7cmresult
deftempbpgfdeclarehorizontalshadingtempshading7cm%
% where 'result' is inserted as last argument:
expandaftertempbexpandafterresult%
sboxbackboxpgfuseshadingtempshading%
begindocument
begintikzpicture
beginaxis[set layers,view=900,
axis lines=left,
grid=major,
no marks,
xmin=0, xmax=1, xlabel=$E$,
ymin=0, ymax=1, ylabel=$lambda$, ylabel style=rotate=-90
]
addplot+[smooth,blue] 1 - (1 - x)^2; % actual curve
beginpgfonlayerpre main
clip plot[variable=x,samples=25,domain=0:1] (x,1 - (1 - x)^2)
|-cycle;
node at (0.5,0.5)useboxbackbox;
endpgfonlayer
% filling
endaxis
endtikzpicture
enddocument

Perfect thank you!
– Jordan Mackie
3 hours ago
It works , but I do get an error:! Undefined control sequence. <argument> backbox l.41 sboxbackboxpgfuseshadingtempshading % ?
– Jordan Mackie
3 hours ago
@JordanMackie Sorry, these statements seem to contradict each other: "it works" and "I get an error". I get this very output from runningpdflatexon the above code, of course without error message.
– marmot
2 hours ago
add a comment |
Welcome to TeX-SE! We usually begin our examples with documentclass, end them with enddocument and do not put non-standard characters in the code that prevents others from copying it. The following is an example of an MWE.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
newsaveboxbackbox
pgfplotscolormaptoshadingspechot7cmresult
deftempbpgfdeclarehorizontalshadingtempshading7cm%
% where 'result' is inserted as last argument:
expandaftertempbexpandafterresult%
sboxbackboxpgfuseshadingtempshading%
begindocument
begintikzpicture
beginaxis[set layers,view=900,
axis lines=left,
grid=major,
no marks,
xmin=0, xmax=1, xlabel=$E$,
ymin=0, ymax=1, ylabel=$lambda$, ylabel style=rotate=-90
]
addplot+[smooth,blue] 1 - (1 - x)^2; % actual curve
beginpgfonlayerpre main
clip plot[variable=x,samples=25,domain=0:1] (x,1 - (1 - x)^2)
|-cycle;
node at (0.5,0.5)useboxbackbox;
endpgfonlayer
% filling
endaxis
endtikzpicture
enddocument

Perfect thank you!
– Jordan Mackie
3 hours ago
It works , but I do get an error:! Undefined control sequence. <argument> backbox l.41 sboxbackboxpgfuseshadingtempshading % ?
– Jordan Mackie
3 hours ago
@JordanMackie Sorry, these statements seem to contradict each other: "it works" and "I get an error". I get this very output from runningpdflatexon the above code, of course without error message.
– marmot
2 hours ago
add a comment |
Welcome to TeX-SE! We usually begin our examples with documentclass, end them with enddocument and do not put non-standard characters in the code that prevents others from copying it. The following is an example of an MWE.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
newsaveboxbackbox
pgfplotscolormaptoshadingspechot7cmresult
deftempbpgfdeclarehorizontalshadingtempshading7cm%
% where 'result' is inserted as last argument:
expandaftertempbexpandafterresult%
sboxbackboxpgfuseshadingtempshading%
begindocument
begintikzpicture
beginaxis[set layers,view=900,
axis lines=left,
grid=major,
no marks,
xmin=0, xmax=1, xlabel=$E$,
ymin=0, ymax=1, ylabel=$lambda$, ylabel style=rotate=-90
]
addplot+[smooth,blue] 1 - (1 - x)^2; % actual curve
beginpgfonlayerpre main
clip plot[variable=x,samples=25,domain=0:1] (x,1 - (1 - x)^2)
|-cycle;
node at (0.5,0.5)useboxbackbox;
endpgfonlayer
% filling
endaxis
endtikzpicture
enddocument

Welcome to TeX-SE! We usually begin our examples with documentclass, end them with enddocument and do not put non-standard characters in the code that prevents others from copying it. The following is an example of an MWE.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
newsaveboxbackbox
pgfplotscolormaptoshadingspechot7cmresult
deftempbpgfdeclarehorizontalshadingtempshading7cm%
% where 'result' is inserted as last argument:
expandaftertempbexpandafterresult%
sboxbackboxpgfuseshadingtempshading%
begindocument
begintikzpicture
beginaxis[set layers,view=900,
axis lines=left,
grid=major,
no marks,
xmin=0, xmax=1, xlabel=$E$,
ymin=0, ymax=1, ylabel=$lambda$, ylabel style=rotate=-90
]
addplot+[smooth,blue] 1 - (1 - x)^2; % actual curve
beginpgfonlayerpre main
clip plot[variable=x,samples=25,domain=0:1] (x,1 - (1 - x)^2)
|-cycle;
node at (0.5,0.5)useboxbackbox;
endpgfonlayer
% filling
endaxis
endtikzpicture
enddocument

answered 3 hours ago
marmotmarmot
114k5145276
114k5145276
Perfect thank you!
– Jordan Mackie
3 hours ago
It works , but I do get an error:! Undefined control sequence. <argument> backbox l.41 sboxbackboxpgfuseshadingtempshading % ?
– Jordan Mackie
3 hours ago
@JordanMackie Sorry, these statements seem to contradict each other: "it works" and "I get an error". I get this very output from runningpdflatexon the above code, of course without error message.
– marmot
2 hours ago
add a comment |
Perfect thank you!
– Jordan Mackie
3 hours ago
It works , but I do get an error:! Undefined control sequence. <argument> backbox l.41 sboxbackboxpgfuseshadingtempshading % ?
– Jordan Mackie
3 hours ago
@JordanMackie Sorry, these statements seem to contradict each other: "it works" and "I get an error". I get this very output from runningpdflatexon the above code, of course without error message.
– marmot
2 hours ago
Perfect thank you!
– Jordan Mackie
3 hours ago
Perfect thank you!
– Jordan Mackie
3 hours ago
It works , but I do get an error:
! Undefined control sequence. <argument> backbox l.41 sboxbackboxpgfuseshadingtempshading % ?– Jordan Mackie
3 hours ago
It works , but I do get an error:
! Undefined control sequence. <argument> backbox l.41 sboxbackboxpgfuseshadingtempshading % ?– Jordan Mackie
3 hours ago
@JordanMackie Sorry, these statements seem to contradict each other: "it works" and "I get an error". I get this very output from running
pdflatex on the above code, of course without error message.– marmot
2 hours ago
@JordanMackie Sorry, these statements seem to contradict each other: "it works" and "I get an error". I get this very output from running
pdflatex on the above code, of course without error message.– marmot
2 hours ago
add a comment |
Jordan Mackie is a new contributor. Be nice, and check out our Code of Conduct.
Jordan Mackie is a new contributor. Be nice, and check out our Code of Conduct.
Jordan Mackie is a new contributor. Be nice, and check out our Code of Conduct.
Jordan Mackie 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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483209%2ffill-area-under-curve-using-colourmap-and-tikz%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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