Search code examples
plottransitionscilab

Scilab Plot with 2D Area and Curve


how to create a Scilab plot with a filled (transparent?) color transition area between two limits. In this case the area should start at the read limit line going to the green limit with color transition from red to green. The blue function line should be part of the plot. I tried to use SFgrayplot but could not manage it. Thanks!

enter image description here


Solution

  • Here is a piece of code to do what you want. Do the background plot before other plots so that the colors will be added to the shaded color map. Adjust the [0,1] limits and it will be fine for your use case:

    x=[0 1];
    y=[0.2 0.8];
    clf;
    ncol=128;
    gcf().color_map = linspace([1 0.6 0.6]',[0.6 1 0.6]',ncol)';
    Sgrayplot(x,y,[0 1;0 1])
    
    plot(0:1,0:1)
    
    xgrid
    gca().grid_position = "foreground"
    

    enter image description here