Filling In Region of 3D Plot

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2















I am trying to fill in the area under this 3D graph, using the idea from this post. Here is a MWE for the function I want to plot under:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));

endaxis
endtikzpicture

enddocument


Here is the result:



enter image description here



Now, here is the MWE with the code that should shade in the sides:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

beginpgfonlayerpre main
addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));
endpgfonlayer

addplot3 [name path = xline, draw = none] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


And this is the result:



enter image description here



Can anyone make any suggestions as to what is going on? It seems when I add multiple functions to the same plot via addplot3, everything gets messed up.



Sorry if this seems like a "just fix this for me," but I have no idea what I'm doing wrong.



EDIT



I now see that for some reason, when adding the new plots to shade in the side, the domain was changed from (0,2) to (-4,4), so setting the domain as you add the plots helps:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

beginpgfonlayerpre main
addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));
endpgfonlayer

addplot3 [name path = xline, draw = none, domain=0:2] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none, domain=0:2] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, domain=0:2, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, domain=0:2, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


And here is the result:



enter image description here



My question now is, why is the original function shifted up?



ANOTHER EDIT



I have figured out a way to get what I want (not including the excellent answers below), but I still have some more concerns. Here is a MWE with a good result:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture

beginaxis[
zmax=1.25,
zmin=0,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
%shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));

addplot3 [name path = xline, draw = none, domain=0:2] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none, domain=0:2] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, domain=0:2, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, domain=0:2, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


Which give this result:



enter image description here



Now, the issue is the %shader=interp, line. When I uncomment this out, this happens:



enter image description here



So does this command force the graph to shift upwards for some reason? Why does this happen?










share|improve this question
























  • I cannot find a picture of exactly what I need, but I just added another picture which is a closer resemblance to what I need. Pretty much I want to fill in the sides of the graph with the same color as the function.

    – Aiden Kenny
    Feb 19 at 10:47















2















I am trying to fill in the area under this 3D graph, using the idea from this post. Here is a MWE for the function I want to plot under:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));

endaxis
endtikzpicture

enddocument


Here is the result:



enter image description here



Now, here is the MWE with the code that should shade in the sides:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

beginpgfonlayerpre main
addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));
endpgfonlayer

addplot3 [name path = xline, draw = none] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


And this is the result:



enter image description here



Can anyone make any suggestions as to what is going on? It seems when I add multiple functions to the same plot via addplot3, everything gets messed up.



Sorry if this seems like a "just fix this for me," but I have no idea what I'm doing wrong.



EDIT



I now see that for some reason, when adding the new plots to shade in the side, the domain was changed from (0,2) to (-4,4), so setting the domain as you add the plots helps:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

beginpgfonlayerpre main
addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));
endpgfonlayer

addplot3 [name path = xline, draw = none, domain=0:2] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none, domain=0:2] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, domain=0:2, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, domain=0:2, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


And here is the result:



enter image description here



My question now is, why is the original function shifted up?



ANOTHER EDIT



I have figured out a way to get what I want (not including the excellent answers below), but I still have some more concerns. Here is a MWE with a good result:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture

beginaxis[
zmax=1.25,
zmin=0,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
%shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));

addplot3 [name path = xline, draw = none, domain=0:2] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none, domain=0:2] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, domain=0:2, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, domain=0:2, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


Which give this result:



enter image description here



Now, the issue is the %shader=interp, line. When I uncomment this out, this happens:



enter image description here



So does this command force the graph to shift upwards for some reason? Why does this happen?










share|improve this question
























  • I cannot find a picture of exactly what I need, but I just added another picture which is a closer resemblance to what I need. Pretty much I want to fill in the sides of the graph with the same color as the function.

    – Aiden Kenny
    Feb 19 at 10:47













2












2








2








I am trying to fill in the area under this 3D graph, using the idea from this post. Here is a MWE for the function I want to plot under:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));

endaxis
endtikzpicture

enddocument


Here is the result:



enter image description here



Now, here is the MWE with the code that should shade in the sides:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

beginpgfonlayerpre main
addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));
endpgfonlayer

addplot3 [name path = xline, draw = none] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


And this is the result:



enter image description here



Can anyone make any suggestions as to what is going on? It seems when I add multiple functions to the same plot via addplot3, everything gets messed up.



Sorry if this seems like a "just fix this for me," but I have no idea what I'm doing wrong.



EDIT



I now see that for some reason, when adding the new plots to shade in the side, the domain was changed from (0,2) to (-4,4), so setting the domain as you add the plots helps:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

beginpgfonlayerpre main
addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));
endpgfonlayer

addplot3 [name path = xline, draw = none, domain=0:2] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none, domain=0:2] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, domain=0:2, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, domain=0:2, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


And here is the result:



enter image description here



My question now is, why is the original function shifted up?



ANOTHER EDIT



I have figured out a way to get what I want (not including the excellent answers below), but I still have some more concerns. Here is a MWE with a good result:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture

beginaxis[
zmax=1.25,
zmin=0,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
%shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));

addplot3 [name path = xline, draw = none, domain=0:2] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none, domain=0:2] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, domain=0:2, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, domain=0:2, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


Which give this result:



enter image description here



Now, the issue is the %shader=interp, line. When I uncomment this out, this happens:



enter image description here



So does this command force the graph to shift upwards for some reason? Why does this happen?










share|improve this question
















I am trying to fill in the area under this 3D graph, using the idea from this post. Here is a MWE for the function I want to plot under:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));

endaxis
endtikzpicture

enddocument


Here is the result:



enter image description here



Now, here is the MWE with the code that should shade in the sides:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

beginpgfonlayerpre main
addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));
endpgfonlayer

addplot3 [name path = xline, draw = none] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


And this is the result:



enter image description here



Can anyone make any suggestions as to what is going on? It seems when I add multiple functions to the same plot via addplot3, everything gets messed up.



Sorry if this seems like a "just fix this for me," but I have no idea what I'm doing wrong.



EDIT



I now see that for some reason, when adding the new plots to shade in the side, the domain was changed from (0,2) to (-4,4), so setting the domain as you add the plots helps:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

beginpgfonlayerpre main
addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));
endpgfonlayer

addplot3 [name path = xline, draw = none, domain=0:2] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none, domain=0:2] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, domain=0:2, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, domain=0:2, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


And here is the result:



enter image description here



My question now is, why is the original function shifted up?



ANOTHER EDIT



I have figured out a way to get what I want (not including the excellent answers below), but I still have some more concerns. Here is a MWE with a good result:



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture

beginaxis[
zmax=1.25,
zmin=0,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
%shader=interp,
opacity=0.5,
]
exp(-(x^2+y^2));

addplot3 [name path = xline, draw = none, domain=0:2] (x,0,0);
% x is the variable
% second 0 is the y coordinate of the leftmost part of the graph
% third 0 is height
addplot3 [name path = yline, draw = none, domain=0:2] (2,y,0);
% y is the variable
% first 2 is the x coordinate of the rightmost part of the graph
% third 0 is height
addplot3 [name path = xcurve, domain=0:2, y domain = 0:0, draw = none]
(x, 0, exp(-x^2));
% now instead of height being 0, it is height of function
addplot3 [name path = ycurve, domain=0:2, y domain = 0:0, draw = none]
(2, x, exp(-(x^2 + 4)));
% same idea
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = xcurve and xline];
% fills in x axis
addplot [color = SteelBlue3, opacity = 0.5, draw = none]
fill between[of = yline and ycurve, reverse = true];

endaxis
endtikzpicture

enddocument


Which give this result:



enter image description here



Now, the issue is the %shader=interp, line. When I uncomment this out, this happens:



enter image description here



So does this command force the graph to shift upwards for some reason? Why does this happen?







tikz-pgf pgfplots 3d






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 19 at 11:58









Raaja

4,98421442




4,98421442










asked Feb 19 at 10:33









Aiden KennyAiden Kenny

4437




4437












  • I cannot find a picture of exactly what I need, but I just added another picture which is a closer resemblance to what I need. Pretty much I want to fill in the sides of the graph with the same color as the function.

    – Aiden Kenny
    Feb 19 at 10:47

















  • I cannot find a picture of exactly what I need, but I just added another picture which is a closer resemblance to what I need. Pretty much I want to fill in the sides of the graph with the same color as the function.

    – Aiden Kenny
    Feb 19 at 10:47
















I cannot find a picture of exactly what I need, but I just added another picture which is a closer resemblance to what I need. Pretty much I want to fill in the sides of the graph with the same color as the function.

– Aiden Kenny
Feb 19 at 10:47





I cannot find a picture of exactly what I need, but I just added another picture which is a closer resemblance to what I need. Pretty much I want to fill in the sides of the graph with the same color as the function.

– Aiden Kenny
Feb 19 at 10:47










1 Answer
1






active

oldest

votes


















5














Something like this?



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture[declare function=f(x,y)=exp(-(x*x+y*y));]
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
f(x,y);

fill[blue] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[blue!80] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;

endaxis
endtikzpicture

enddocument


enter image description here



Or, if you do the fills with



fill[SteelBlue3] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[SteelBlue3] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;


you get



enter image description here



Notice that I added pgfplotssetcompat=1.16. If you do not want that, you need to prepend the coordinates with axis cs:



fill[SteelBlue3] (axis cs:0,0,-1) -- plot[variable=x,domain=0:2] (axis cs:x,0,f(x,0)) -- (axis cs:2,0,-1) --
cycle;
fill[SteelBlue3] (axis cs:2,0,-1) -- plot[variable=y,domain=0:2] (axis cs:2,y,f(2,y))
-- (axis cs:2,2,-1) --cycle;





share|improve this answer

























  • Exactly! I would like the sides to be the same color, but that can obviously be changed very easily.

    – Aiden Kenny
    Feb 19 at 10:55











  • @AidenKenny Yes, that's simple, I added something. (In principle one could do it then in one stretch but that does not make the code substantially simpler).

    – marmot
    Feb 19 at 11:04










Your Answer








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

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

else
createEditor();

);

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



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475636%2ffilling-in-region-of-3d-plot%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









5














Something like this?



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture[declare function=f(x,y)=exp(-(x*x+y*y));]
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
f(x,y);

fill[blue] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[blue!80] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;

endaxis
endtikzpicture

enddocument


enter image description here



Or, if you do the fills with



fill[SteelBlue3] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[SteelBlue3] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;


you get



enter image description here



Notice that I added pgfplotssetcompat=1.16. If you do not want that, you need to prepend the coordinates with axis cs:



fill[SteelBlue3] (axis cs:0,0,-1) -- plot[variable=x,domain=0:2] (axis cs:x,0,f(x,0)) -- (axis cs:2,0,-1) --
cycle;
fill[SteelBlue3] (axis cs:2,0,-1) -- plot[variable=y,domain=0:2] (axis cs:2,y,f(2,y))
-- (axis cs:2,2,-1) --cycle;





share|improve this answer

























  • Exactly! I would like the sides to be the same color, but that can obviously be changed very easily.

    – Aiden Kenny
    Feb 19 at 10:55











  • @AidenKenny Yes, that's simple, I added something. (In principle one could do it then in one stretch but that does not make the code substantially simpler).

    – marmot
    Feb 19 at 11:04















5














Something like this?



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture[declare function=f(x,y)=exp(-(x*x+y*y));]
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
f(x,y);

fill[blue] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[blue!80] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;

endaxis
endtikzpicture

enddocument


enter image description here



Or, if you do the fills with



fill[SteelBlue3] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[SteelBlue3] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;


you get



enter image description here



Notice that I added pgfplotssetcompat=1.16. If you do not want that, you need to prepend the coordinates with axis cs:



fill[SteelBlue3] (axis cs:0,0,-1) -- plot[variable=x,domain=0:2] (axis cs:x,0,f(x,0)) -- (axis cs:2,0,-1) --
cycle;
fill[SteelBlue3] (axis cs:2,0,-1) -- plot[variable=y,domain=0:2] (axis cs:2,y,f(2,y))
-- (axis cs:2,2,-1) --cycle;





share|improve this answer

























  • Exactly! I would like the sides to be the same color, but that can obviously be changed very easily.

    – Aiden Kenny
    Feb 19 at 10:55











  • @AidenKenny Yes, that's simple, I added something. (In principle one could do it then in one stretch but that does not make the code substantially simpler).

    – marmot
    Feb 19 at 11:04













5












5








5







Something like this?



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture[declare function=f(x,y)=exp(-(x*x+y*y));]
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
f(x,y);

fill[blue] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[blue!80] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;

endaxis
endtikzpicture

enddocument


enter image description here



Or, if you do the fills with



fill[SteelBlue3] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[SteelBlue3] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;


you get



enter image description here



Notice that I added pgfplotssetcompat=1.16. If you do not want that, you need to prepend the coordinates with axis cs:



fill[SteelBlue3] (axis cs:0,0,-1) -- plot[variable=x,domain=0:2] (axis cs:x,0,f(x,0)) -- (axis cs:2,0,-1) --
cycle;
fill[SteelBlue3] (axis cs:2,0,-1) -- plot[variable=y,domain=0:2] (axis cs:2,y,f(2,y))
-- (axis cs:2,2,-1) --cycle;





share|improve this answer















Something like this?



PassOptionsToPackageusenames,dvipsnames,table,x11namesxcolor
documentclass[a4paper, 12pt]article
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibrarycolormaps,fillbetween

begindocument

begintikzpicture[declare function=f(x,y)=exp(-(x*x+y*y));]
pgfdeclarelayerpre main
pgfsetlayerspre main,main

beginaxis[
zmax=1.25,
view = 4545,
grid=minor,
colormap=mycolcolor=(SteelBlue3), color=(SteelBlue3),
xlabel = $x$,
ylabel = $y$,
zlabel = $f(x,y)$,
]

addplot3[
surf,
samples=30,
domain=0:2,
shader=interp,
opacity=0.5,
]
f(x,y);

fill[blue] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[blue!80] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;

endaxis
endtikzpicture

enddocument


enter image description here



Or, if you do the fills with



fill[SteelBlue3] (0,0,-1) -- plot[variable=x,domain=0:2] (x,0,f(x,0)) -- (2,0,-1) --
cycle;
fill[SteelBlue3] (2,0,-1) -- plot[variable=y,domain=0:2] (2,y,f(2,y))
-- (2,2,-1) --cycle;


you get



enter image description here



Notice that I added pgfplotssetcompat=1.16. If you do not want that, you need to prepend the coordinates with axis cs:



fill[SteelBlue3] (axis cs:0,0,-1) -- plot[variable=x,domain=0:2] (axis cs:x,0,f(x,0)) -- (axis cs:2,0,-1) --
cycle;
fill[SteelBlue3] (axis cs:2,0,-1) -- plot[variable=y,domain=0:2] (axis cs:2,y,f(2,y))
-- (axis cs:2,2,-1) --cycle;






share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 19 at 11:24

























answered Feb 19 at 10:50









marmotmarmot

108k5133251




108k5133251












  • Exactly! I would like the sides to be the same color, but that can obviously be changed very easily.

    – Aiden Kenny
    Feb 19 at 10:55











  • @AidenKenny Yes, that's simple, I added something. (In principle one could do it then in one stretch but that does not make the code substantially simpler).

    – marmot
    Feb 19 at 11:04

















  • Exactly! I would like the sides to be the same color, but that can obviously be changed very easily.

    – Aiden Kenny
    Feb 19 at 10:55











  • @AidenKenny Yes, that's simple, I added something. (In principle one could do it then in one stretch but that does not make the code substantially simpler).

    – marmot
    Feb 19 at 11:04
















Exactly! I would like the sides to be the same color, but that can obviously be changed very easily.

– Aiden Kenny
Feb 19 at 10:55





Exactly! I would like the sides to be the same color, but that can obviously be changed very easily.

– Aiden Kenny
Feb 19 at 10:55













@AidenKenny Yes, that's simple, I added something. (In principle one could do it then in one stretch but that does not make the code substantially simpler).

– marmot
Feb 19 at 11:04





@AidenKenny Yes, that's simple, I added something. (In principle one could do it then in one stretch but that does not make the code substantially simpler).

– marmot
Feb 19 at 11:04

















draft saved

draft discarded
















































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


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

But avoid


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

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

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




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475636%2ffilling-in-region-of-3d-plot%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

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay