ILNumerics PlotCube中多个表面的相同颜色条 [英] Same color bar for multiple surfaces in ILNumerics PlotCube

查看:161
本文介绍了ILNumerics PlotCube中多个表面的相同颜色条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个绘图立方体中绘制多个曲面.但是我不能使它们具有相同的颜色条.我已经定义了ILColorbar并将其添加到表面,但是它绘制了两个具有不同数字的颜色条.两个表面是否可能具有相同的颜色条?此外,如何将文本添加到颜色栏(标题,标签)?非常感谢你.这是一个示例:

I plot multiple surfaces in one plot cube. But I cannot make them to have the same color bar. I have defined an ILColorbar and added them to the surfaces but it plots two color bars with different numbers. Is it possible for the both surfaces to have the same color bar? Moreover, how can I add text to the color bar (title, labels)? Thank you very much. Here is an example:

    private void ilPanel1_Load(object sender, EventArgs e)
    {
        var scene = new ILScene();
        // add a new plot cube 
        var pc = scene.Add(new ILPlotCube());
        pc.TwoDMode = false;
        // Create Data
        ILArray<float> A = ILSpecialData.torus(0.75f, .25f);
        ILArray<float> B = ILSpecialData.torus(3.0f, .65f);
        // Add the surface
        var sf1 = new ILSurface(A);
        var sf2 = new ILSurface(B);

        pc.Add(sf1);
        pc.Add(sf2);
        sf1.Colormap = Colormaps.Jet;
        sf2.Colormap = Colormaps.Jet;

        var cb = new ILColorbar();
        sf1.Add(cb);
        sf2.Add(cb);
        ilPanel1.Scene = scene;
    }

推荐答案

使它们使用相同的DataRange.我在表面上使用UpdateColormapped()提供相同的Tuple<float,float>.这告诉他们使用颜色表中的哪些颜色.由于某些原因,我无法使用相应的ILSurface构造函数.这可能是错误吗? (在这种情况下,有人应该提出问题吗?)

Make them use the same DataRange. I use UpdateColormapped() on the surfaces to provide the same Tuple<float,float>. This tells them which colors from the colormap to use. For some reasons I could not use the corresponding ILSurface constructor. This might be a bug? (Someone should file an issue in that case ?)

颜色条的修改与其他任何对象一样:您可以按常规方式向其添加新的形状/标签.使用Padding属性,以便为标签留出更多空间:

The colorbar is modified just like any other object: you can add new shapes / labels to it the regular way. Use the Padding property, in order to make more room for your labels:

private void ilPanel1_Load(object sender, EventArgs e) {
    var scene = new ILScene();
    // add a new plot cube 
    var pc = scene.Add(new ILPlotCube(twoDMode:false));

    // Create Data
    ILArray<float> A = ILSpecialData.torus(0.75f, .25f);
    ILArray<float> B = ILSpecialData.torus(3.0f, .65f);
    // Add the surfaces
    var cdr = Tuple.Create<float,float>(-0.6f, 0.6f);  
    var sf1 = new ILSurface(0);
    var sf2 = new ILSurface(0);
    // provide the same datarange to both surfaces
    sf1.UpdateColormapped(A, dataRange: cdr);
    sf2.UpdateColormapped(B, dataRange: cdr);

    pc.Add(sf1);
    pc.Add(sf2);
    sf1.Colormap = Colormaps.Jet;
    sf2.Colormap = Colormaps.Jet;

    var cb = new ILColorbar() {
        Padding = new SizeF(10,30),
        Children = {
            new ILLabel("Title") {
                Position = new Vector3(.5f,.1f,0),
                Anchor = new PointF(.5f,.7f),
                Font = new Font(DefaultFont, FontStyle.Bold)
            },
            new ILLabel("Label") {
                Position = new Vector3(.12f,.5f,0),
                Rotation = -Math.PI / 2,
            }
        }
    };
    sf1.Add(cb);
    ilPanel1.Scene = scene;
}

您可能知道以下事实:根本不需要使用绘图多维数据集?如果将圆环添加到scene.Camera的正下方,则会得到一个不变形的圆环:

You probably are aware of the fact, that you do not have to use a plot cube at all? If we add the torus right below scene.Camera we get a torus without distortion:

这篇关于ILNumerics PlotCube中多个表面的相同颜色条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆