Tikz/Pgf - Surf plot with smooth color transitionColor-bar - surf plotpgfplots: Color a 3D surf plot based on...

How do I avoid the "chosen hero" feeling?

Why does this relation fail symmetry and transitivity properties?

Identical projects by students at two different colleges: still plagiarism?

Why is Shelob considered evil?

What are some idioms that means something along the lines of "switching it up every day to not do the same thing over and over"?

I have trouble understanding this fallacy: "If A, then B. Therefore if not-B, then not-A."

How to not let the Identify spell spoil everything?

How to put text above column in minipage?

Minimum Viable Product for RTS game?

What is an efficient way to digitize a family photo collection?

Insecure private-key encryption

Players preemptively rolling, even though their rolls are useless or are checking the wrong skills

Why is it that Bernie Sanders is always called a "socialist"?

Equivalent of "illegal" for violating civil law

Why do objects rebound after hitting the ground?

How unreachable are Jupiter's moons from Mars with the technology developed for going to Mars?

Does rolling friction increase speed of a wheel?

Is it possible to detect 100% of SQLi with a simple regex?

How can I handle players killing my NPC outside of combat?

Solving the linear first order differential equation?

Is practicing on a digital piano harmful to an experienced piano player?

Calculating the strength of an ionic bond that contains poly-atomic ions

Fraction within another fraction

Would water spill from a bowl in a Bag of Holding?



Tikz/Pgf - Surf plot with smooth color transition


Color-bar - surf plotpgfplots: Color a 3D surf plot based on y-valueHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?Show mark labels near marks and not centered in ybar interaval graphTikz and exponential style tick labelTikZ: Circle with color transitionpgfplots: percentage in matrix plotTikz : Draw smooth convex3D Piecewise Plot with varying bounds in Tikz/PGFSmooth projection of a surf plot - tikz/gnuplot













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
    51 mins ago
















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
    51 mins ago














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 50 mins ago







Thanos

















asked 5 hours ago









ThanosThanos

6,0751354107




6,0751354107








  • 1





    With pleasure! No problem!

    – Thanos
    51 mins ago














  • 1





    With pleasure! No problem!

    – Thanos
    51 mins ago








1




1





With pleasure! No problem!

– Thanos
51 mins ago





With pleasure! No problem!

– Thanos
51 mins ago










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
    2 hours ago













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

    – marmot
    2 hours ago











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

    – Thanos
    2 hours ago











  • @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
    2 hours ago











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

    – Thanos
    2 hours ago











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
    2 hours ago













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

    – marmot
    2 hours ago











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

    – Thanos
    2 hours ago











  • @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
    2 hours ago











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

    – Thanos
    2 hours ago
















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
    2 hours ago













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

    – marmot
    2 hours ago











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

    – Thanos
    2 hours ago











  • @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
    2 hours ago











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

    – Thanos
    2 hours ago














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 2 hours ago

























answered 3 hours ago









marmotmarmot

103k4122233




103k4122233













  • 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
    2 hours ago













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

    – marmot
    2 hours ago











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

    – Thanos
    2 hours ago











  • @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
    2 hours ago











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

    – Thanos
    2 hours ago



















  • 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
    2 hours ago













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

    – marmot
    2 hours ago











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

    – Thanos
    2 hours ago











  • @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
    2 hours ago











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

    – Thanos
    2 hours ago

















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
2 hours ago







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
2 hours ago















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

– marmot
2 hours ago





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

– marmot
2 hours ago













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

– Thanos
2 hours ago





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

– Thanos
2 hours ago













@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
2 hours ago





@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
2 hours ago













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

– Thanos
2 hours ago





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

– Thanos
2 hours ago


















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

Szabolcs (Ungheria) Altri progetti | Menu di navigazione48°10′14.56″N 21°29′33.14″E /...

Discografia di Klaus Schulze Indice Album in studio | Album dal vivo | Singoli | Antologie | Colonne...

How to make inet_server_addr() return localhost in spite of ::1/128RETURN NEXT in Postgres FunctionConnect to...