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

前端 未结 2 1268
南笙
南笙 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

    The proper way to do it would be to provide an n*3 matrix of color values, for n data points.

    C = zeros(size(x,2), 3);
    C(x>=150 & x<=200,1) = 1; % red
    C(x<150 | x>200,3) = 1; % blue
    scatter(x, y, 25, C, 'd', 'filled');
    

提交回复
热议问题