[Mathematica]Frustratedhow to color a plot according to the values?

  • Context: Mathematica 
  • Thread starter Thread starter hanson
  • Start date Start date
  • Tags Tags
    Color Plot
Click For Summary

Discussion Overview

The discussion revolves around how to create a contour plot in Mathematica that colors the plot based on the values of the function, specifically using blue for negative values and red for positive values, with a gradient between these two colors.

Discussion Character

  • Technical explanation, Exploratory

Main Points Raised

  • One participant expresses frustration in finding a way to color a contour plot in Mathematica according to the values of the function, specifically requesting blue for negative values and red for positive values with a gradient.
  • Another participant suggests adjusting the contour option and contour style, indicating that these options can be found in the help context.
  • A third participant mentions the use of ColorFunction, providing a link to the documentation and suggesting a specific syntax for implementing a gradient color scheme, although they admit to not remembering the exact syntax.
  • A later reply indicates that the original poster found a user-written Mathematica notebook that meets their requirements.

Areas of Agreement / Disagreement

Participants do not appear to disagree on the methods suggested, but the original poster's frustration indicates a lack of clarity or ease in finding a solution. The discussion does not reach a consensus on a specific method, as the original poster ultimately finds an external resource.

Contextual Notes

The discussion does not clarify specific assumptions about the function being plotted or the exact requirements for the gradient. The syntax for ColorFunction remains unresolved as participants provide suggestions without confirming their correctness.

Who May Find This Useful

Users of Mathematica looking to create contour plots with custom color gradients based on function values may find this discussion helpful.

hanson
Messages
312
Reaction score
0
Hi all.
I have been searching over the web for some time, kind of frustrated...
I would like to plot the contourplot of a function, and I would like the contourplot to be colored.
The rule is that...the negative values should be blue in colors and the positive values should be red in colors, but I also want some gradient between these two limits...
I suppose this can be quite easily done, but I still don't know how to do that...
Anyone knows? Please help. Thanks.
 
Physics news on Phys.org
Try playing with the contour option:
contour-># of contour lines
and contourstyle

they should be in the help context
 
ColorFunction

http://documents.wolfram.com/mathematica/functions/ColorFunction

I can't remember the syntax (haven't had a Mathematica license in years), but you want something like ColorFunction -> (RGBColor[1.0#, 0.0, (1.0-1.0#)]&) or similar - you can fiddle with the constants to change the parametric variation, even make it nonlinear if you want.
 
Last edited by a moderator:
Thanks for the replies!
I have found a user-written Mathematica notebook which do exactly what i want. Thanks.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K