2011-07-04 100 views
5

给定两个向量图和类似下面的不透明度控制覆盖地块

as = VectorPlot[{Cos[y], Sin[x] }, {x, -3, 3}, {y, -3, 3}, 
       VectorScale -> Automatic, VectorColorFunction -> "Rainbow" 
    ]; 
bs = StreamPlot[{Cos[y], Sin[x] }, {x, -3, 3}, {y, -3, 3}, 
       VectorScale -> Automatic, StreamColorFunction -> "Rainbow" 
    ]; 
cs = ContourPlot[Cos[x] + Sin[y], {x, -3, 3}, {y, -3, 3}, 
       ColorFunction -> "BlueGreenYellow" 
    ]; 
Show[cs, bs, as] 

enter image description here

轮廓图,我们可以看到基本叠加的工作是深受显示完成[]。但我的问题是如何控制背景等高线图的不透明度 cs?另外,如何在类似以下的颜色函数中插入“BlueGreenYellow”类型的配色方案?

ContourPlot[Cos[x] + Sin[y], {x, -3, 3}, {y, -3, 3}, 
      ColorFunction -> (Directive[Opacity[#],Blue] &) 
]; 

回答

7

您可以尝试使用BaseStyle如下:

cs = ContourPlot[Cos[x] + Sin[y], {x, -3, 3}, {y, -3, 3}, 
       ColorFunction -> "BlueGreenYellow", 
       BaseStyle -> Directive[Opacity[0.5]] 
    ]; 

enter image description here

10

我不相信jmlopez”解决方案是正确的,因为载体和框架也部分透明。我认为,这是更好地插入Opacity命令到Graphics对象,这将保持不透明的载体:

as = VectorPlot[{Cos[y], Sin[x]}, {x, -3, 3}, {y, -3, 3}, 
     VectorScale -> Automatic, VectorColorFunction -> "Rainbow"]; 
bs = StreamPlot[{Cos[y], Sin[x]}, {x, -3, 3}, {y, -3, 3}, 
     VectorScale -> Automatic, StreamColorFunction -> "Rainbow"]; 
cs = ContourPlot[Cos[x] + Sin[y], {x, -3, 3}, {y, -3, 3}, 
     ColorFunction -> "BlueGreenYellow"]; 

cs2 = MapAt[{Opacity[0.5], #} &, cs, 1]; 

Show[cs2, bs, as] 

enter image description here


第二个问题一直没有解决。你可以像这样结合的不透明度和颜色渐变:

ContourPlot[Cos[x] + Sin[y], {x, -3, 3}, {y, -3, 3}, 
    ColorFunction -> ({Opacity[#], ColorData["BlueGreenYellow"][#]} &) 
] 

enter image description here