The density figure like this can be plotted in Python with Contour, and I can’t do this with Mathematica in a elliptical shape. The same command Contour in Mathematica give a square picture, can Mathematica plot the same shape like Python?
And the picture is a simple example, the data can be chosen freely.
If you want to do the mesh lines and other details, you can use more options. These make no sense to the plot because I just made things up and copied the MeshFunction from an example in the documentation to show you.
DensityPlot[Sin[x + Cos[y]], {x, y} \[Element] Disk[{0, 0}, {6, 3}],
AspectRatio -> Automatic, BoundaryStyle -> Directive[Red, Thick],
Frame -> None, Mesh -> 10,
MeshFunctions -> {Re[Sqrt[#1 + I #2]] &, Im[Sqrt[#1 + I #2]] &}]
gives
Thanks for your help! But if I want to do this with the data in a list shape, rather than a continous function. How to achieve it in this case?
I read the documentation in detail, but can’t solve it.
test = Table[{x, y, x + y}, {x, 0, 10}, {y, 0, 10}];
test = Flatten[test, 1];
ListDensityPlot[test,AspectRatio -> Automatic]
By the way, I with I knew why
ContourPlot[x, Element[{x, y}, Disk[]]]
Plot3D[x, Element[{x, y}, Disk[]]]
draw the plot on a disk, but the following does not:
ParametricPlot3D[{x, y, x}, Element[{x, y}, Disk[]]]
Actually, it did up to version 12.0. But then that capability was inexplicably removed.
Tony,
Use RegionFunction to specify the region. For example, this specifies a ring:
ListDensityPlot[test, AspectRatio -> Automatic,
RegionFunction -> Function[{x, y, z}, 2 < x^2 + y^2 < 6]]
Regards
Neil
Gianluca,
This works:
ParametricPlot3D[{x, y, x}, Element[{x, y}, Disk[]],
RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 1]]
or better yet,
ParametricPlot3D[{x, y, x}, Element[{x, y}, Disk[]],
RegionFunction -> Function[{x, y, z}, Element[{x, y}, Disk[]]]]
but you should report that the element syntax no longer automatically limits the region.
Regards
Neil
Yes, we can do it with RegionFunction, but it is not so convenient for Polygons, for example. The new behaviour of ParametricPlot3D is declared explicitly in the documentation, and I cannot report it as a bug, maybe as a complaint?
Thank you sir! This way can help me solve this problem greatly!
Regards
Tony


