سؤال

Is it possible to invert a colormap in ILNumerics? i am using the Jet colour map at the moment and would like to invert it so blue is at the top and red at the bottom, how can i do this without inverting the z value of all points?

This is my code:

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

Which produces this:

Surface Plot

هل كانت مفيدة؟

المحلول

You can retrieve the current colormap from the surface (or from an ILColormap instance) and simply invert the positions of the individual color mapping items within the colormap. In my example the first row of the colordata are overwritten with their mirror-view:

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

The cmdata are afterwards used to create a new colormap which is than assigned to the surface.

See the relevant documentation here: http://ilnumerics.net/managing-colormaps.html

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top