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;
    }

enter image description here

有帮助吗?

解决方案

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 ?)

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;
}

torus with plot cube and custom data range

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:

Torus with no distortion

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top