separate y axis on right and left (even and odd data) with IMAGESC

4 ビュー (過去 30 日間)
Jessica Frau
Jessica Frau 2023 年 4 月 2 日
コメント済み: Jessica Frau 2023 年 4 月 9 日
Hello,
I have a matrix containing some data that I want to plot with imagesc. I want to separate rows representation on y axis (even rows on right and odd on left), in a way that they don't overlap themselves.
The code i was trying is this:
figure(12);
yyaxis left
ylabel('Odd Side');
imagesc(RateR_new.Flux(1:2:end,1));
yticklabels = 1:2:32;
yticks = linspace(1, size(RateR_new.Flux(1:2:end,1), 1), numel(yticklabels));
set(gca, 'XTick',xticks, 'XTickLabel', xlabels);
set(gca, 'YTick', yticks, 'YTickLabel', flipud(yticklabels(:)));
yyaxis right;
ylabel('Even Side');
im = imagesc(RateR_new.Flux(2:2:end,1));
yticklabels1 = 2:2:32;
yticks1 = linspace(1, size(RateR_new.Flux(2:2:end,1), 1), numel(yticklabels1));
set(gca, 'YTick', yticks1, 'YTickLabel', flipud(yticklabels1(:)));
But in this case i have even and odd data overlap themselves.
Hope to someone that can help me. Thanks in advance!

採用された回答

埃博拉酱
埃博拉酱 2023 年 4 月 3 日
編集済み: 埃博拉酱 2023 年 4 月 7 日
Preprocess your data like:
reshape(RateR_new.Flux(:,1),2,[])'
Not sure if this is what you want. If not, it's best to draw a diagram of what exactly you want to do.
Update 20230407
If you want to share a graph with two different Y-axes, you can do this:
Data=rand(30);
figure;
yyaxis left
imagesc(Data);
yticks(1:2:30);
yyaxis right
axis ij
ylim([0.5,30.5]);
yticks(2:2:30);
If the data is also separated, you may use tiledlayout:
DataO=Data(1:2:end,:);
DataE=Data(2:2:end,:);
figure;
tiledlayout(1,2,TileSpacing='none',Padding='tight');
nexttile;
imagesc(DataO,YData=[1,29]);
yticks(1:2:30);
Ax=nexttile;
imagesc(DataE,YData=[2,30]);
Ax.YAxisLocation='right';
yticks(2:2:30);
  3 件のコメント
Image Analyst
Image Analyst 2023 年 4 月 7 日
If you have any more questions, then attach your data (RateR_new.Flux) and code to read it in with the paperclip icon after you read this:
Jessica Frau
Jessica Frau 2023 年 4 月 9 日
it solved my problem. Thank u very much!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by