Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Jessica Frau
Jessica Frau le 2 Avr 2023
Commenté : Jessica Frau le 9 Avr 2023
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!

Réponse acceptée

埃博拉酱
埃博拉酱 le 3 Avr 2023
Modifié(e) : 埃博拉酱 le 7 Avr 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 commentaires
Image Analyst
Image Analyst le 7 Avr 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:
Jessica Frau
Jessica Frau le 9 Avr 2023
it solved my problem. Thank u very much!!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by