Highlight a part of a plot by drawing it in a different color

前端 未结 2 1286
南笙
南笙 2021-01-16 04:51

Given a plot with e.g. a curve like shown on the following figure I want to highlight the curve in the interval 150 <= x <= 200. I would prefer simply drawing this int

2条回答
  •  独厮守ぢ
    2021-01-16 04:59

    A quick example:

    %# plot data
    x = linspace(0,2*pi,75);
    y = sin(x);
    plot(x, y, 'b.')
    
    %# higlight points of interest
    idx = (4 <= x & x <= 6);
    hold on, plot(x(idx), y(idx), 'r.')
    hold off
    

    screenshot

提交回复
热议问题