【问题标题】:Invert Colormap in ILNumerics在 ILNumerics 中反转颜色图
【发布时间】:2014-02-06 14:35:44
【问题描述】:

是否可以在 ILNumerics 中反转颜色图?我目前正在使用 Jet 颜色图,并希望将其反转,因此蓝色在顶部,红色在底部,我如何在不反转所有点的 z 值的情况下做到这一点?

这是我的代码:

    //p are the points im plotting
    ILSurface surface = new ILSurface(p, colormap: Colormaps.Jet);

产生这个:

【问题讨论】:

    标签: c# color-mapping ilnumerics


    【解决方案1】:

    您可以从表面(或从 ILColormap 实例)检索当前颜色图,并简单地反转颜色图中各个颜色映射项的位置。在我的示例中,颜色数据的第一行被它们的镜像覆盖:

    private void ilPanel1_Load(object sender, EventArgs e) {
        ILArray<float> A = ILSpecialData.sincf(40, 50);
        ilPanel1.Scene.Add(new ILPlotCube(twoDMode: false) {
            new ILSurface(A) { new ILColorbar() }
        });
    
        // fetch surface
        var surface = ilPanel1.Scene.First<ILSurface>();
        // fetch current colormap data
        ILArray<float> cmdata = surface.Colormap.Data;
        // invert their positions
        cmdata[":;0"] = cmdata["end:-1:0;:"];
        // make new colormap and assign
        surface.Colormap = new ILColormap(cmdata);
        // configure after all modifications
        surface.Configure();
    }
    

    cmdata 之后用于创建一个新的颜色图,然后分配给表面。

    在此处查看相关文档:http://ilnumerics.net/managing-colormaps.html

    【讨论】:

    • 完美正是我想要的,谢谢! :D
    猜你喜欢
    • 1970-01-01
    • 2014-08-21
    • 2013-12-24
    • 2021-09-23
    • 2011-06-05
    • 1970-01-01
    • 1970-01-01
    • 2018-05-09
    • 1970-01-01
    相关资源
    最近更新 更多