在MATLAB图形中用于标识0和1的透明背景 [英] Transparent background for identification of 0 and 1 in a MATLAB figure

查看:271
本文介绍了在MATLAB图形中用于标识0和1的透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码中有阳光和日食检测.我想在我生成的每个情节中强调日光和日食检测.

I've sunlight and eclipse detection in my code. I'd like to highlight sunlight and eclipse detection in every plot I'm generating.

假设

sun_avail = 0; % means spacecraft is in eclipse
sun_avail = 1; % means spacecraft is in sunlit

我需要在Matlab图形中绘制一组变量(向量(X,Y,Z)),我想这样做

I've set of variables (vectors (X,Y,Z)) needed to be plot in matlab figure which I'd do like this

fig = figure();
set(fig, 'name', 'Quaternions', 'NumberTitle', 'off');
subplot(4,1,1);
plot(t,Qp(:,1),'b','linewidth',2);
title('Quaternions wrt ref frame selected','fontweight','b')
hold on;plot(t,q_dp(:,1),'-.m','linewidth',2);
grid;zoom;
legend('Gyro Q Attitude (Actual Gyro)','Body Q Attitude (Ideal Gyro)');
xlabel('time in secs','fontweight','b')
ylabel('q1','fontweight','b')

subplot(4,1,2);
plot(t,Qp(:,2),'b','linewidth',2);
hold on;plot(t,q_dp(:,2),'-.m','linewidth',2);
grid;zoom;
xlabel('time in secs','fontweight','b'); 
ylabel('q2','fontweight','b')

subplot(4,1,3);
plot(t,Qp(:,3),'b','linewidth',2);
hold on;plot(t,q_dp(:,3),'-.m','linewidth',2);
grid;zoom;
xlabel('time in secs','fontweight','b');
ylabel('q3','fontweight','b')

subplot(4,1,4);
plot(t,Qp(:,4),'b','linewidth',2);
hold on;plot(t,q_dp(:,4),'-.m','linewidth',2);
grid;zoom;
xlabel('time in secs','fontweight','b');
ylabel('q4','fontweight','b')

图看起来像这样

有什么方法可以在背景中像某些透明颜色一样突出显示,以识别上图中matlab图中被日光照射和日蚀的部分.

Is there any way to highlight like some transparent color in the background to identify the sunlit and eclipse portions in the above matlab figure.

推荐答案

您可以使用

You can use patch for this purpose. Adjust the loop according to your data.

plot(randperm(100));   hold on;    plot(randperm(100));  %plotting some random data      
%if sunlight remains for 20 units and 40 is the interval from which it repeats and
%100-20=80 is the last occurence then
for k=0:40:80  
    patch([k 20+k 20+k k], [0 0 100 100],'y','EdgeColor','none','FaceAlpha',0.3);
end  

这篇关于在MATLAB图形中用于标识0和1的透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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