trying to make many subjects the same color in graph
2 次查看(过去 30 天)
显示 更早的评论
Hello!
I am trying to make groups of subjects on a graph, and I am trying to define the subject and give it a certain color. there was a code online that said that said that something like my code below should work, but i am still getting errors. does anyone have any ideas? Thanks times a billion!
figure;
% plot(f, allspectrums_cortex_young, 'r');
% plot(f, allspectrums_ventricle_young, 'y');
% plot(f, allspectrums_cortex_elderly, 'b')
% plot(f, allspectrums_ventricle_elderly, 'g')
l1 = plot(f, allspectrums_cortex_young, 'r');
hold on
l2 = plot(f, allspectrums_ventricle_young, 'y');
l3 = plot(f, allspectrums_cortex_elderly, 'b')
l4 = plot(f, allspectrums_ventricle_elderly, 'g')
legend([l1, l2, l3, l4], {'ventricle cortex', 'ventricle young', 'ventricle elderly', 'cortex elderly'});
hold off
xlabel('Frequency (in hertz)');
ylabel('Power');
title('Young vs. Elderly Power - 4th Ventricle and Cortex')
0 个评论
采纳的回答
Meg Noah
2020-1-7
With some fake data, this works:
% fake data
f = -pi:0.01:pi;
allspectrums_cortex_young = sin(2.*f + pi/3) + 0.05*rand(size(f));
allspectrums_ventricle_young = sin(3.*f + pi/2) + 0.05*rand(size(f));
allspectrums_cortex_elderly = sin(2.5.*f + 0) + 0.05*rand(size(f));
allspectrums_ventricle_elderly = sin(0.75.*f + pi/6) + 0.05*rand(size(f));
% code
figure;
l1 = plot(f, allspectrums_cortex_young, 'r','DisplayName','ventricle cortex');
hold on
l2 = plot(f, allspectrums_ventricle_young, 'color', [0.8 0.7 0],'DisplayName','ventricle young');
l3 = plot(f, allspectrums_cortex_elderly, 'b','DisplayName','ventricle elderly');
l4 = plot(f, allspectrums_ventricle_elderly, 'color', [0 0.75 0],'DisplayName','cortex elderly');
legend('location','best');
hold off
xlabel('Frequency (in hertz)');
ylabel('Power');
title('Young vs. Elderly Power - 4th Ventricle and Cortex')
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Behavior and Psychophysics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!