# How to make a density plot for an isotropic function written in cylindrical coordinates?

$$f(\rho,z)=2\rho^2+\frac{2}{3}z^2 \quad$$ is a function in the cylindrical coordinate system $$(\rho,\theta,z)$$

The function $$f(\rho,z)$$ is isotropic because it does not depend on the angle $$\theta$$. Therefore, a plot of the density distribution of the function $$f(\rho,z)$$ can be obtained. I would like to get a density plot of the function $$f$$, where the function's dependence on $$z$$ is shown by the density (in color).

How could this graph be plot?

Perhaps DensityPlot or ContourPlot are suitable for this type of plot.

You just need to define the function you want and use one of the following Mathematica functions. If I understand what you are asking for

f[\[Rho]_, z_] := 2 \[Rho]^2 + (2/3) z^2

DensityPlot[f[\[Rho], z], {\[Rho], 0, 5}, {z, -5, 5},
PlotRange -> All, PlotPoints -> 100,
ColorFunction -> "TemperatureMap",
FrameLabel -> {"\[Rho]", "z", "Density"}, PlotLegends -> Automatic]



or


f[\[Rho]_, z_] := 2 \[Rho]^2 + (2/3) z^2

ContourPlot[f[\[Rho], z], {\[Rho], 0, 5}, {z, -5, 5}, Contours -> 20,
ColorFunction -> "TemperatureMap", ContourLabels -> True,
FrameLabel -> {"\[Rho]", "z"}, PlotLegends -> Automatic]


Updated

To plot the projection of a sphere onto a plane while showing the distance from a specific point on the sphere to the plane as a density distribution (color), here's how you can do it:

• Define the parameters of the sphere and the point:
(* Sphere parameters *)
sphereCenter = {0, 0, 3}; (* Center of the sphere *)

(* Point parameters *)
pointOnSphere = {0, 0, 5}; (* Coordinates of a point on the sphere *)

• Create a function that calculates the distance from the point on the sphere to the plane for a given point on the plane:
distanceToPlane[pointOnPlane_, pointOnSphere_] :=
EuclideanDistance[pointOnSphere, pointOnPlane]

• Create a density distribution plot where the x and y axes represent the coordinates of the plane, and the color represents the distance from the point on the sphere to the plane:
DensityPlot[
distanceToPlane[{x, y, 0}, pointOnSphere],

• Thanks for the answer, but I meant something else. On the abscissa axis in your case is [\Rho], on the ordinate axis is z, the density shows the distribution of the function depending on these two coordinates. I would like to get the following graph: on the abscissa axis is [\Rho], on the ordinate axis is [\Rho], and the density shows the distribution of the function depending on z. Sep 5, 2023 at 21:09