给出两个矢量图和如下的等高线图
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]
我们可以看到Show []完成了基本的叠加工作。但我的问题是如何控制背景轮廓图的不透明度 cs?另外,如何在颜色函数中插入“BlueGreenYellow”类型颜色方案,如下所示?
ContourPlot[Cos[x] + Sin[y], {x, -3, 3}, {y, -3, 3},
ColorFunction -> (Directive[Opacity[#],Blue] &)
];
答案 0 :(得分:11)
我不相信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]
第二个问题从未得到解决。您可以组合不透明度和颜色渐变,如下所示:
ContourPlot[Cos[x] + Sin[y], {x, -3, 3}, {y, -3, 3},
ColorFunction -> ({Opacity[#], ColorData["BlueGreenYellow"][#]} &)
]
答案 1 :(得分:7)
您可以尝试使用BaseStyle
,如下所示:
cs = ContourPlot[Cos[x] + Sin[y], {x, -3, 3}, {y, -3, 3},
ColorFunction -> "BlueGreenYellow",
BaseStyle -> Directive[Opacity[0.5]]
];