【问题标题】:Opacity control for overlaying plots覆盖图的不透明度控制
【发布时间】:2011-09-27 23:22:37
【问题描述】:

给定两个矢量图和一个等高线图,如下所示

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] &)
];

【问题讨论】:

    标签: graphics wolfram-mathematica


    【解决方案1】:

    我不相信 jmlopez 的解决方案是正确的,因为矢量和框架也是部分透明的。我认为最好在Graphics 对象中插入一个Opacity 命令,这样会保留不透明的向量:

    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"][#]} &)
    ]
    

    【讨论】:

      【解决方案2】:

      您可以尝试如下使用BaseStyle

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

      【讨论】:

        猜你喜欢
        • 2011-04-19
        • 2016-09-28
        • 2013-02-25
        • 2013-01-27
        • 1970-01-01
        • 2013-08-28
        • 2011-02-08
        • 2018-10-02
        • 2012-09-06
        相关资源
        最近更新 更多