0
$\begingroup$

$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.

$\endgroup$

1 Answer 1

1
$\begingroup$

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]

enter image description here

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]

enter image description here

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 *)
sphereRadius = 2;
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], 
  {x, -sphereRadius, sphereRadius}, {y, -sphereRadius, sphereRadius}, 
  PlotRange -> All, ColorFunction -> "Rainbow", 
  PlotLegends -> Automatic, FrameLabel -> {"x", "y"}, 
  PlotLabel -> "Distance from Sphere Point to Plane"]

enter image description here

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – Mam Mam
    Sep 5, 2023 at 21:09
  • $\begingroup$ I will give an example: how to plot a projection of a sphere onto a plane, in such a way that, through the distribution of density (color), show the distance from a specific point on the sphere to the plane? $\endgroup$
    – Mam Mam
    Sep 5, 2023 at 21:09
  • $\begingroup$ @MamMam I have updated my answer, according to what I understand from your comments. I think it might be helpful $\endgroup$ Sep 5, 2023 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.