Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ContourPlot and ColorFunction Opacity

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93755] Re: [mg93714] ContourPlot and ColorFunction Opacity
  • From: "David Park" <djmpark at comcast.net>
  • Date: Tue, 25 Nov 2008 07:15:35 -0500 (EST)
  • References: <10198237.1227519579820.JavaMail.root@m02>

There are several ways to do this. One method is to put the GridLines in
front.

ContourPlot[Cos[x y], {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]},
 GridLines -> Automatic,
 RegionFunction -> Function[{x, y, z}, \[Pi] < x^3 + y^3 < \[Pi]^3], 
 BoundaryStyle -> Red,
 ColorFunction -> "TemperatureMap",
 Method -> {"GridLinesInFront" -> True}]

A second method is to write a fancier ColorFunction.

ContourPlot[Cos[x y], {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]},
 GridLines -> Automatic,
 RegionFunction -> Function[{x, y, z}, \[Pi] < x^3 + y^3 < \[Pi]^3], 
 BoundaryStyle -> Red,
 ColorFunction -> 
  Function[f, Opacity[.7, ColorData["TemperatureMap"][f]]]]

A third method, for those who have the Presentations package, is to simply
set the Opacity before drawing the contours.

Needs["Presentations`Master`"]

Draw2D[
 {Opacity[.7],
  ContourDraw[Cos[x y], {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]},
   RegionFunction -> Function[{x, y, z}, \[Pi] < x^3 + y^3 < \[Pi]^3],
    BoundaryStyle -> Red,
   ColorFunction -> "TemperatureMap"]},
 GridLines -> Automatic,
 Frame -> True]


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark  


From: alpinekarst [mailto:alpinekarst at gmail.com] 


Dear All,

I am hoping that one of the Gurus here can help me figure out how to
adjust the opacity for a ContourPlot ColorFunction in Mathematica 6.0.3

say for example I have a 2D ContourPlot plot such as:

ContourPlot[Cos[x y], {x, -Pi, Pi}, {y, -Pi, Pi},
 GridLines -> Automatic,
 RegionFunction -> Function[{x, y, z}, Pi < x^3 + y^3 < Pi^3],
 BoundaryStyle -> Red, ColorFunction -> "TemperatureMap"]

How can I adjust the Opacity of the filled region so that the
gridlines are somewhat visible within the boundary defined by the
RegionFunction?  Using a constant would be fine or even better some
generic decay function from the centroid of the region.

I have tried defining the opacity in the color function multiple ways
such as:
{Directive[Opacity[0.5]], ColorData["TemperatureMap"][#1] &}
but keep getting BoxForm and Graphics Directive errors.

I'm thinking of resorting to replacement rules against AbsoluteOptions
but that's bound to get ugly and I am hoping that there is a better
way? This is probably quite simple...but not for me today.

Thanks.




  • Prev by Date: Re: Integration - another Integer as a result
  • Next by Date: Re: Integration - another Integer as a result
  • Previous by thread: Re: ContourPlot and ColorFunction Opacity
  • Next by thread: Primed Symbols in Mathematica