Search code examples
ilnumerics

control contour plot X and Y axis in ILNumerics


When using Surface, I can pass a grid for X and Y axis to the constructor:

Array<float> z = new float[,]
{
      {1, 2, 3 },
      {4, 5, 6 }
};
Array<float> x = new float[,]
{
      {-0.5f, 0, 0.5f },
};
Array<float> y = new float[,]
{
      {-10, -1 },
};
var linSurface = new Surface(z, x, y, colormap: Colormaps.Hsv);
var linContour = new ContourPlot(z, colormap: Colormaps.Hsv);

Can I do something similar (control X and Y axis) for ContourPlot?


Solution

  • ContourPlot currently does not have the option to specify custom coordinates for X or Y values. However, you can use a trick to 'move' the contour plot to custom positions. For it to work, put the ContourPlot into a Group node. Groups allow to translate their content to arbitrary positions. They also allow to stretch the content.

    For example, to create an axis range [10...110] for X and [20,220] for Y (pseudo code, have not tested):

    var linContour = new Group(
                        scale: new Vector3(100, 200, 0), 
                        translate: new Vector3(10,20,1)) { 
                        new ContourPlot(z, colormap: Colormaps.Hsv) 
                     };