Plotting 3D Function with Color Saturation in Mathematica

In summary: Saturation is alpha channel.In summary, you want to plot a function in 3D such that the saturation of the color at any point is given by:S = f(x, y, z)so, when f(x, y, z) is maximum, i want the color at (x, y, z) to be say saturated Red [rgb(255, 255, 0)] and when it is minimum, i want the color to be white.
  • #1
rohanprabhu
414
2
I want to plot a function in 3D such that the saturation of the color at any point is given by:

[tex]
S = f(x, y, z)
[/tex]

so, when f(x, y, z) is maximum, i want the color at (x, y, z) to be say saturated Red [rgb(255, 255, 0)] and when it is minimum, i want the color to be white.

How do i do that in Mathematica?
 
Physics news on Phys.org
  • #2
Are you talking about a surface in 3D colored? Or more like a density plot, say random particles.

If its the first:

F[x_, y_] = x/Exp[x^2 + y^2];
Plot3D[F[x, y], {x, -2, 2}, {y, -2, 2},
ColorFunction -> Function[{x, y, z}, RGBColor[1, 1 - z, 1 - z]]]

Sort of does what you ask.
 
  • #3
Well.. in the example you gave, the function represents a set of points which satisfy a given condition. However, i want that each and every point is assigned a color, based on the co-ordinates of the point. How do i do that?
 
  • #4
So you mean like a 3D density plot. If it drew a pixel at every coordinate, how would you see anything behind the front face of the data? Or are you looking for something like, at certain points its transparent and at others its not?

Because if its fully opaque you'll only see the bounds of the plot and no data inside. Even so I'll try to do it. I'm thinking your best approach (since there's no such thing as DensityPlot3D) is to have it draw a sphere or cube at each coordinate and color accordingly.

I've done something like this before when trying to make graphics for some 3D Crystalline grain growth simulations. Its a pain and I ended up making my own stuff using OpenDX (which I don't really recommend, its difficult).

so I guess let me ask you this, is your data a function of coordinates, or a table of datapoints?
 
  • #5
K.J.Healey said:
So you mean like a 3D density plot. If it drew a pixel at every coordinate, how would you see anything behind the front face of the data? Or are you looking for something like, at certain points its transparent and at others its not?

Because if its fully opaque you'll only see the bounds of the plot and no data inside. Even so I'll try to do it. I'm thinking your best approach (since there's no such thing as DensityPlot3D) is to have it draw a sphere or cube at each coordinate and color accordingly.

I've done something like this before when trying to make graphics for some 3D Crystalline grain growth simulations. Its a pain and I ended up making my own stuff using OpenDX (which I don't really recommend, its difficult).

so I guess let me ask you this, is your data a function of coordinates, or a table of datapoints?

What I want to do is visualize the behavior of a Spherical Wave. The color at each point should give me the value of the.. let's say Electric Field if it is an EM Wave. Something like:

[tex]
X = X_o Sin[k\sqrt{x^2 + y^2 + z^2} + \omega t]
[/tex]

and i want 't' to be manipulated by the parameter supplied through Animate[] rather than Manipulate[], but that's a different thing. Also, in the above case, the greater 'X' is.. the more opaque i want the color to be.
 
  • #6
Yeah, that's basically a 3D density plot. I'll keep looking at it, but remember that what you're talking about isn't saturation, its the alpha channel.
The function Hue[h,s,b,a] the last channel is the alpha.
Maybe there's soemthing you can do in the plot where ColorFunction-> something with Hue[50,50,50,F[x,y,z]] or something.
 
  • #7
Or do something like this:
(Where Alph is the function describing the transparency coordinates as a function of xyz)

F[x_, y_] = x/Exp[x^2 + y^2];
Alph[x_, y_, z_] = z; (*Anything here*)
Plot3D[F[x, y], {x, -2, 2}, {y, -2, 2},
ColorFunction ->
Function[{x, y, z}, RGBColor[1, 0, 0, Alph[x, y, z]]]]
 

1. What is Mathematica and how is it used for plotting 3D functions?

Mathematica is a powerful software program used for mathematical and scientific computation and visualization. It has built-in functions and tools for creating, manipulating, and plotting 3D functions and data.

2. How can I plot a 3D function with color saturation in Mathematica?

To plot a 3D function with color saturation in Mathematica, you can use the Plot3D function and specify the color function using the ColorFunction option. This will map the function values to a color scale, allowing you to visualize the function in 3D with varying color intensity.

3. What are the benefits of using color saturation in 3D function plots?

Color saturation in 3D function plots can provide a visual representation of the function's value at different points in the plot. This can make it easier to interpret and analyze the function, as well as identify patterns and trends in the data.

4. Can I customize the color scale used in a 3D function plot in Mathematica?

Yes, you can customize the color scale used in a 3D function plot by specifying the ColorFunction option with a custom function. You can also adjust the color range and blending using the ColorFunctionScaling and Blend functions.

5. Are there any limitations to using color saturation in 3D function plots?

One limitation of using color saturation in 3D function plots is that it can be difficult to accurately interpret the exact value of the function at a specific point on the plot. Additionally, too many colors or a poorly chosen color scale can make the plot difficult to read and understand.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
752
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
247
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
890
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
Back
Top