通过以其他颜色绘制来突出显示绘图的一部分 [英] Highlight a part of a plot by drawing it in a different color

查看:79
本文介绍了通过以其他颜色绘制来突出显示绘图的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个情节,例如如下图所示的曲线,我想突出显示间隔为150< = x< = 200的曲线.我宁愿简单地以红色而不是蓝色绘制此间隔.

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 interval in red instead of blue.

是否有比将曲线分成3组/3个连接曲线零件更好的方法? (3个间隔,第一个间隔为蓝色,第二个间隔为红色,第三个间隔为蓝色).感谢您提供任何提示!

Is there a better way to do this than splitting my curve in 3 sets / 3 connecting curve parts? (3 intervals, first one for blue, sencond one for red, third one again for blue). Thanks for any hint!

推荐答案

一个简单的例子:

%# 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

这篇关于通过以其他颜色绘制来突出显示绘图的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆