Filling In Region of 3D Plot
Clash Royale CLAN TAG#URR8PPP
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:
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:
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:
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:
Now, the issue is the %shader=interp,
line. When I uncomment this out, this happens:
So does this command force the graph to shift upwards for some reason? Why does this happen?
tikz-pgf pgfplots 3d
add a comment |
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:
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:
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:
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:
Now, the issue is the %shader=interp,
line. When I uncomment this out, this happens:
So does this command force the graph to shift upwards for some reason? Why does this happen?
tikz-pgf pgfplots 3d
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
add a comment |
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:
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:
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:
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:
Now, the issue is the %shader=interp,
line. When I uncomment this out, this happens:
So does this command force the graph to shift upwards for some reason? Why does this happen?
tikz-pgf pgfplots 3d
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:
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:
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:
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:
Now, the issue is the %shader=interp,
line. When I uncomment this out, this happens:
So does this command force the graph to shift upwards for some reason? Why does this happen?
tikz-pgf pgfplots 3d
tikz-pgf pgfplots 3d
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
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
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;
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
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
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%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
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
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
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;
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
add a comment |
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
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
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;
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
add a comment |
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
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
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;
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
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
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;
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
add a comment |
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
add a comment |
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');
);
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%2f475636%2ffilling-in-region-of-3d-plot%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');
);
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');
);
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');
);
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
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