How to plot multiple time series cell arrays as a shadowed area
3 ビュー (過去 30 日間)
古いコメントを表示
Hi guys!
I have the following cell data (each column represents a different algorithm for comparison; each row represents a experiment run):
* The data is attached.
Using this code:
figure
hold on
cellfun(@plot,mutation1)
I get this plot:
Question 1: How can I represent each column of data in a specific color in the plot using the code above?
Three columns have constant data (single lines: purple, blue and green). Two columns have data with small variations (the other two multicolored lines on the graph).
Question 2: Would it be possible to represent these two multicolored lines (which are made up of a series of other lines) as a shaded area with a middle line?
Thank you very much!
0 件のコメント
採用された回答
Star Strider
2023 年 9 月 19 日
編集済み: Star Strider
2023 年 9 月 19 日
Answer 2: Yes, although it takes a bit of exploring to determine what those curves are. I left in my ‘exploration’ steps (commented-out). After that, this is straightforward.
Try this —
LD = load('mutation1.mat');
mutation1 = LD.mutation1
colororder(turbo(numel(mutation1))) % Use The 'turbo' 'colormap' To Define The Colours
mutationmtx = cell2mat(reshape(mutation1, 1,[]));
% figure
% surf(mutationmtx, 'EdgeColor','none')
% colormap(turbo)
% xlabel('Columns')
% ylabel('Rows')
%
% figure
% plot((1:size(mutationmtx,2)), mutationmtx(1,:))
% hold on
% plot((1:size(mutationmtx,2)), mutationmtx(150,:))
% hold off
% grid
% legend('1','150', 'Location','best')
Lv1 = mutationmtx(1,:) > 0.3;
Lv2 = mutationmtx(150,:) > 0.05;
highest = max(mutationmtx(:,Lv1 & ~Lv2),[],2);
lowest = min(mutationmtx(:,Lv1 & Lv2), [],2);
middleline = median([highest lowest],2);
% figure
% plot(highest, 'g')
% hold on
% plot(lowest, 'r')
% hold off
v = (1:numel(highest)).';
figure
hold on
cellfun(@plot,mutation1)
patch([v; flip(v)], [highest; flip(lowest)], [1 1 1]*0.75, 'FaceAlpha',0.5)
plot(middleline, '-g', 'LineWidth',1.5)
% Ax = gca;
% Ax.XScale = 'log';
EDIT — (19 Sep 2023 at 13:52)
Forgot about ‘middle line’, Now added.
.
4 件のコメント
Star Strider
2023 年 9 月 20 日
As always, my pleasure!
No worries — some concepts are difficult to put into words regardless of the language, especially some mathematical concepts. I am happy that I could help you get this sorted.
.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!