Message Boards Message Boards

0
|
3087 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Specify a color in a contour plot according to density?

Posted 7 years ago

The following code allows one to manipulate the parameters and see the corresponding contours for a bivariate normal. What I would like to do is make the background white after the density is below a value say .02. Using the following code creates a dark blue background. I was wondering if is blue because the density is less a particular value but am not sure. Is this possible to specify a density value, below which you can specify a color? I played around with ContourShading but with no success. Here is my code:

Manipulate[
 ContourPlot[
  PDF[BinormalDistribution[{Subscript[\[Mu], 1], Subscript[\[Mu], 
     2]}, {Subscript[\[Sigma], 1], Subscript[\[Sigma], 
     2]}, \[Rho]], {x, y}], {x, -3, 3}, {y, -3, 3}, 
  ContourLabels -> True, PlotRange -> All, 
  PlotPoints -> 40], {Subscript[\[Mu], 1], -2, 2}, {Subscript[\[Mu], 
  2], -2, 2}, {Subscript[\[Sigma], 1], 1, 3}, {Subscript[\[Sigma], 2],
   1, 3}, {\[Rho], -0.9, 0.9}]
POSTED BY: Terry Ackerman
4 Replies

It's one of the thousands of features of Mathematica. Look up ColorData, ColorSchemes in the documentation. There is also a ColorSchemes palette.

POSTED BY: Gianluca Gorni

Terry,

You can find the gradients listed here: http://reference.wolfram.com/language/guide/ColorSchemes.html

POSTED BY: Neil Singer
Posted 7 years ago

Gianluca, Your suggestion is very helpful and what I was looking for. I have a couple of follow-up questions. Did you create the GreenBrownTerrain? Could you send me where to look to create other color profiles? Thanks for all your help! Terry

POSTED BY: Terry Ackerman

You may play around with PlotLegends and ColorFunction. For example

Manipulate[
 ContourPlot[
  PDF[BinormalDistribution[{Subscript[\[Mu], 1], 
     Subscript[\[Mu], 2]}, {Subscript[\[Sigma], 1], 
     Subscript[\[Sigma], 2]}, \[Rho]], {x, y}], {x, -3, 3}, {y, -3, 
   3}, ContourLabels -> True, PlotRange -> All, PlotPoints -> 40, 
  PlotLegends -> Automatic, 
  ColorFunction -> (ColorData["GreenBrownTerrain"][
      1 - #] &)], {Subscript[\[Mu], 1], -2, 
  2}, {Subscript[\[Mu], 2], -2, 2}, {Subscript[\[Sigma], 1], 1, 
  3}, {Subscript[\[Sigma], 2], 1, 3}, {\[Rho], -0.9, 0.9}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract