Tikz/Pgf - Surf plot with smooth color transition












3















I am drawing a surf 3d plot in Tikz/Pgf using gnuplot. This surface need to be projected on a plane, which can be achieved by adding another surf plot.



The thing is that the transition between colors, in both surf plots actually is not very smooth, despite using



shader=interp


One possibility is to increase the number of samples however building becomes slow and I cannot exceed 75 samples.



An example code can be found right next



documentclass{standalone}
usepackage{pgfplots}
usepackage{tikz}
usepgfplotslibrary{patchplots}


begin{document}

begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
addplot3[surf,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};

addplot3[surf,
samples=51,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
point meta=rawz,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(x**2+y**2)};
end{axis}
end{tikzpicture}

end{document}


and the result of this code is the following image



enter image description here



Any idea on how to make a smoother transition from color to color?










share|improve this question




















  • 1





    With pleasure! No problem!

    – Thanos
    Feb 24 at 21:00
















3















I am drawing a surf 3d plot in Tikz/Pgf using gnuplot. This surface need to be projected on a plane, which can be achieved by adding another surf plot.



The thing is that the transition between colors, in both surf plots actually is not very smooth, despite using



shader=interp


One possibility is to increase the number of samples however building becomes slow and I cannot exceed 75 samples.



An example code can be found right next



documentclass{standalone}
usepackage{pgfplots}
usepackage{tikz}
usepgfplotslibrary{patchplots}


begin{document}

begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
addplot3[surf,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};

addplot3[surf,
samples=51,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
point meta=rawz,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(x**2+y**2)};
end{axis}
end{tikzpicture}

end{document}


and the result of this code is the following image



enter image description here



Any idea on how to make a smoother transition from color to color?










share|improve this question




















  • 1





    With pleasure! No problem!

    – Thanos
    Feb 24 at 21:00














3












3








3


1






I am drawing a surf 3d plot in Tikz/Pgf using gnuplot. This surface need to be projected on a plane, which can be achieved by adding another surf plot.



The thing is that the transition between colors, in both surf plots actually is not very smooth, despite using



shader=interp


One possibility is to increase the number of samples however building becomes slow and I cannot exceed 75 samples.



An example code can be found right next



documentclass{standalone}
usepackage{pgfplots}
usepackage{tikz}
usepgfplotslibrary{patchplots}


begin{document}

begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
addplot3[surf,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};

addplot3[surf,
samples=51,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
point meta=rawz,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(x**2+y**2)};
end{axis}
end{tikzpicture}

end{document}


and the result of this code is the following image



enter image description here



Any idea on how to make a smoother transition from color to color?










share|improve this question
















I am drawing a surf 3d plot in Tikz/Pgf using gnuplot. This surface need to be projected on a plane, which can be achieved by adding another surf plot.



The thing is that the transition between colors, in both surf plots actually is not very smooth, despite using



shader=interp


One possibility is to increase the number of samples however building becomes slow and I cannot exceed 75 samples.



An example code can be found right next



documentclass{standalone}
usepackage{pgfplots}
usepackage{tikz}
usepgfplotslibrary{patchplots}


begin{document}

begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
addplot3[surf,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};

addplot3[surf,
samples=51,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
point meta=rawz,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(x**2+y**2)};
end{axis}
end{tikzpicture}

end{document}


and the result of this code is the following image



enter image description here



Any idea on how to make a smoother transition from color to color?







tikz-pgf pgfplots 3d gnuplot smooth






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 24 at 21:00







Thanos

















asked Feb 24 at 16:32









ThanosThanos

6,0801454107




6,0801454107








  • 1





    With pleasure! No problem!

    – Thanos
    Feb 24 at 21:00














  • 1





    With pleasure! No problem!

    – Thanos
    Feb 24 at 21:00








1




1





With pleasure! No problem!

– Thanos
Feb 24 at 21:00





With pleasure! No problem!

– Thanos
Feb 24 at 21:00










1 Answer
1






active

oldest

votes


















4














If your main concern is the color transitions, then you may want to use a polar plot because the function only depends on the radius and not on the angle. Then you could increase the samples in radial direction while leaving the samples in angular direction comparatively small.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
data cs=polar,
]
addplot3[surf, samples=37,samples y=101,
shader=interp,
z buffer=sort,
%mesh/ordering=y varies,
domain=0:360,
y domain=3.1:0,
]
gnuplot {besj0(y**2)};

addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here



As a "side-effect" the wiggles will also disappear as they result from plotting a rotationally symmetric function in cartesian coordinates.



And here is a combination of a cartesian and a polar plot.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
addplot3[surf, samples=75,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};
addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
data cs=polar,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here






share|improve this answer


























  • Thank you very much for your answer! The point is that in the 3d surface the folding of the function is more prominent, therefore the wiggles are indeed needed! I could however use a polar plot on the projection. Is this possible?

    – Thanos
    Feb 24 at 18:58













  • @Thanos Yes, but I do not understand what you mean by "folding".

    – marmot
    Feb 24 at 19:00











  • I mean the wiggles you mentioned in the side-effect.

    – Thanos
    Feb 24 at 19:00











  • @Thanos But aren't the wiggles "unphysical", meaning that the true Bessel function doesn't have them (since they imply an angular dependence, which J0 does not have)?

    – marmot
    Feb 24 at 19:02











  • @ marmot You are perfectly right. However, I believe that for illustration reasons, someone can better observe the oscillating behaviour.

    – Thanos
    Feb 24 at 19:07











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%2f476469%2ftikz-pgf-surf-plot-with-smooth-color-transition%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









4














If your main concern is the color transitions, then you may want to use a polar plot because the function only depends on the radius and not on the angle. Then you could increase the samples in radial direction while leaving the samples in angular direction comparatively small.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
data cs=polar,
]
addplot3[surf, samples=37,samples y=101,
shader=interp,
z buffer=sort,
%mesh/ordering=y varies,
domain=0:360,
y domain=3.1:0,
]
gnuplot {besj0(y**2)};

addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here



As a "side-effect" the wiggles will also disappear as they result from plotting a rotationally symmetric function in cartesian coordinates.



And here is a combination of a cartesian and a polar plot.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
addplot3[surf, samples=75,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};
addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
data cs=polar,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here






share|improve this answer


























  • Thank you very much for your answer! The point is that in the 3d surface the folding of the function is more prominent, therefore the wiggles are indeed needed! I could however use a polar plot on the projection. Is this possible?

    – Thanos
    Feb 24 at 18:58













  • @Thanos Yes, but I do not understand what you mean by "folding".

    – marmot
    Feb 24 at 19:00











  • I mean the wiggles you mentioned in the side-effect.

    – Thanos
    Feb 24 at 19:00











  • @Thanos But aren't the wiggles "unphysical", meaning that the true Bessel function doesn't have them (since they imply an angular dependence, which J0 does not have)?

    – marmot
    Feb 24 at 19:02











  • @ marmot You are perfectly right. However, I believe that for illustration reasons, someone can better observe the oscillating behaviour.

    – Thanos
    Feb 24 at 19:07
















4














If your main concern is the color transitions, then you may want to use a polar plot because the function only depends on the radius and not on the angle. Then you could increase the samples in radial direction while leaving the samples in angular direction comparatively small.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
data cs=polar,
]
addplot3[surf, samples=37,samples y=101,
shader=interp,
z buffer=sort,
%mesh/ordering=y varies,
domain=0:360,
y domain=3.1:0,
]
gnuplot {besj0(y**2)};

addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here



As a "side-effect" the wiggles will also disappear as they result from plotting a rotationally symmetric function in cartesian coordinates.



And here is a combination of a cartesian and a polar plot.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
addplot3[surf, samples=75,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};
addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
data cs=polar,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here






share|improve this answer


























  • Thank you very much for your answer! The point is that in the 3d surface the folding of the function is more prominent, therefore the wiggles are indeed needed! I could however use a polar plot on the projection. Is this possible?

    – Thanos
    Feb 24 at 18:58













  • @Thanos Yes, but I do not understand what you mean by "folding".

    – marmot
    Feb 24 at 19:00











  • I mean the wiggles you mentioned in the side-effect.

    – Thanos
    Feb 24 at 19:00











  • @Thanos But aren't the wiggles "unphysical", meaning that the true Bessel function doesn't have them (since they imply an angular dependence, which J0 does not have)?

    – marmot
    Feb 24 at 19:02











  • @ marmot You are perfectly right. However, I believe that for illustration reasons, someone can better observe the oscillating behaviour.

    – Thanos
    Feb 24 at 19:07














4












4








4







If your main concern is the color transitions, then you may want to use a polar plot because the function only depends on the radius and not on the angle. Then you could increase the samples in radial direction while leaving the samples in angular direction comparatively small.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
data cs=polar,
]
addplot3[surf, samples=37,samples y=101,
shader=interp,
z buffer=sort,
%mesh/ordering=y varies,
domain=0:360,
y domain=3.1:0,
]
gnuplot {besj0(y**2)};

addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here



As a "side-effect" the wiggles will also disappear as they result from plotting a rotationally symmetric function in cartesian coordinates.



And here is a combination of a cartesian and a polar plot.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
addplot3[surf, samples=75,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};
addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
data cs=polar,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here






share|improve this answer















If your main concern is the color transitions, then you may want to use a polar plot because the function only depends on the radius and not on the angle. Then you could increase the samples in radial direction while leaving the samples in angular direction comparatively small.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
data cs=polar,
]
addplot3[surf, samples=37,samples y=101,
shader=interp,
z buffer=sort,
%mesh/ordering=y varies,
domain=0:360,
y domain=3.1:0,
]
gnuplot {besj0(y**2)};

addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here



As a "side-effect" the wiggles will also disappear as they result from plotting a rotationally symmetric function in cartesian coordinates.



And here is a combination of a cartesian and a polar plot.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepgfplotslibrary{patchplots}

begin{document}
begin{tikzpicture}
begin{axis} [width=textwidth,
height=textwidth,
ultra thick,
colorbar,
colorbar style={yticklabel style={text width=2.5em,
align=right,
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
},
},
xlabel={$rho_x=k_xr_x$},
ylabel={$rho_y=k_yr_y$},
zlabel={$j_l(rho)$},
3d box,
zmax=2.5,
xmin=-3, xmax=3,
ymin=-3.1, ymax=3.1,
ytick={-3, -2, ..., 3},
grid=major,
grid style={line width=.1pt, draw=gray!30, dashed},
x tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
y tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
z tick label style={/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
]
addplot3[surf, samples=75,
shader=interp,
mesh/ordering=y varies,
domain=-3:3,
y domain=-3.1:3.1,
]
gnuplot {besj0(x**2+y**2)};
addplot3[surf, samples=36, samples y=101,
shader=interp,
%mesh/ordering=y varies,
domain=0:360,
y domain=0:3.1,
point meta=rawz,
data cs=polar,
z filter/.code={defpgfmathresult{2.5}},
]
gnuplot {besj0(y**2)};


end{axis}
end{tikzpicture}

end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 24 at 19:37

























answered Feb 24 at 18:44









marmotmarmot

105k4126241




105k4126241













  • Thank you very much for your answer! The point is that in the 3d surface the folding of the function is more prominent, therefore the wiggles are indeed needed! I could however use a polar plot on the projection. Is this possible?

    – Thanos
    Feb 24 at 18:58













  • @Thanos Yes, but I do not understand what you mean by "folding".

    – marmot
    Feb 24 at 19:00











  • I mean the wiggles you mentioned in the side-effect.

    – Thanos
    Feb 24 at 19:00











  • @Thanos But aren't the wiggles "unphysical", meaning that the true Bessel function doesn't have them (since they imply an angular dependence, which J0 does not have)?

    – marmot
    Feb 24 at 19:02











  • @ marmot You are perfectly right. However, I believe that for illustration reasons, someone can better observe the oscillating behaviour.

    – Thanos
    Feb 24 at 19:07



















  • Thank you very much for your answer! The point is that in the 3d surface the folding of the function is more prominent, therefore the wiggles are indeed needed! I could however use a polar plot on the projection. Is this possible?

    – Thanos
    Feb 24 at 18:58













  • @Thanos Yes, but I do not understand what you mean by "folding".

    – marmot
    Feb 24 at 19:00











  • I mean the wiggles you mentioned in the side-effect.

    – Thanos
    Feb 24 at 19:00











  • @Thanos But aren't the wiggles "unphysical", meaning that the true Bessel function doesn't have them (since they imply an angular dependence, which J0 does not have)?

    – marmot
    Feb 24 at 19:02











  • @ marmot You are perfectly right. However, I believe that for illustration reasons, someone can better observe the oscillating behaviour.

    – Thanos
    Feb 24 at 19:07

















Thank you very much for your answer! The point is that in the 3d surface the folding of the function is more prominent, therefore the wiggles are indeed needed! I could however use a polar plot on the projection. Is this possible?

– Thanos
Feb 24 at 18:58







Thank you very much for your answer! The point is that in the 3d surface the folding of the function is more prominent, therefore the wiggles are indeed needed! I could however use a polar plot on the projection. Is this possible?

– Thanos
Feb 24 at 18:58















@Thanos Yes, but I do not understand what you mean by "folding".

– marmot
Feb 24 at 19:00





@Thanos Yes, but I do not understand what you mean by "folding".

– marmot
Feb 24 at 19:00













I mean the wiggles you mentioned in the side-effect.

– Thanos
Feb 24 at 19:00





I mean the wiggles you mentioned in the side-effect.

– Thanos
Feb 24 at 19:00













@Thanos But aren't the wiggles "unphysical", meaning that the true Bessel function doesn't have them (since they imply an angular dependence, which J0 does not have)?

– marmot
Feb 24 at 19:02





@Thanos But aren't the wiggles "unphysical", meaning that the true Bessel function doesn't have them (since they imply an angular dependence, which J0 does not have)?

– marmot
Feb 24 at 19:02













@ marmot You are perfectly right. However, I believe that for illustration reasons, someone can better observe the oscillating behaviour.

– Thanos
Feb 24 at 19:07





@ marmot You are perfectly right. However, I believe that for illustration reasons, someone can better observe the oscillating behaviour.

– Thanos
Feb 24 at 19:07


















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%2f476469%2ftikz-pgf-surf-plot-with-smooth-color-transition%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 change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents