Search code examples
plotoctavetransparencypatch

Plotting a transparency patch on octave


I made a plot on octave and to put on evidence a specific region of the plot I want to put over a rectangle or patch e.g. yellow but transparent in order to see the plot behind. I googled but I didn't find a solution. Please, could you help me? Thanks


Solution

  • Use a rectangle object, and reach into its properties to set its child's transparency.

    X = [0:0.1:10];
    p = plot( X, 3 * sin(X) + X )
    grid on
    r = rectangle('position', [3, 1, 3, 3], 'curvature', 0.25, 'edgecolor','k', 'facecolor', 'y' )
    set( get(r, 'children'), 'facealpha', 0.25 )