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

1 view (last 30 days)
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!

Accepted Answer

埃博拉酱
埃博拉酱 on 3 Apr 2023
Edited: 埃博拉酱 on 7 Apr 2023
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 Comments
Image Analyst
Image Analyst on 7 Apr 2023
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:

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!