Como girar imagem e eixos juntos no Matlab?
Código 1 em que inverter verticalmente e / ou horizontalmente não afetaaxes()
; Código 2, onde a solução proposta não produz a saída esperada
close all; clear all; clc;
x = [5 8];
y = [3 6];
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
C2 = C(:,end:-1:1,:); %# horizontal flip
C3 = C(end:-1:1,:,:); %# vertical flip
C4 = C(end:-1:1,end:-1:1,:); %# horizontal+vertical flip
% https://stackoverflow.com/a/4010203/54964
subplot(2,2,1), imagesc(x,y,C)
subplot(2,2,2), imagesc(x,y,C2)
subplot(2,2,3), imagesc(x,y,C3)
subplot(2,2,4), imagesc(x,y,C4)
%% Rotations of axes() unsuccessfully
% https://stackoverflow.com/a/15071734/54964
figure
subplot(2,2,1), imagesc(x,y,C)
x = linspace(1, size(C, 2), numel(x)); % reverse only x
set(gca, 'XTick', x, 'XTickLabel', x)
subplot(2,2,2), imagesc(x,y,C2)
x = linspace(1, size(C, 2), numel(x)); % reverse back x
set(gca, 'XTick', x, 'XTickLabel', x) % reverse y
y = linspace(1, size(C, 1), numel(y));
set(gca, 'YTick', y, 'YTickLabel', flipud(y(:)))
subplot(2,2,3), imagesc(x,y,C3)
x = linspace(1, size(C, 2), numel(x)); % now both x,y reversed
set(gca, 'XTick', x, 'XTickLabel', x)
subplot(2,2,4), imagesc(x,y,C4)
Fig. 1 Saída onde o eixo permanece intocado, mas as imagens são invertidas corretamente, Fig. 2 Saída da tentativa com movimentoxticks
/yticks
Saída esperada:
Fig.1 (canto superior esquerdo) todos corretos nos eixos com a figuraFig.2 (canto superior direito) eixo y correto, mas eixo x de 8 a 5Fig. 3 (eixo inferior esquerdo) eixo y de 6 a 3, mas o eixo x está corretoFig.4 (inferior direito) eixo y correto, mas eixo x de 3 a 6Tentativa 2Código
% 1 start of vector 2 end of vector 3 length of vector
figure
subplot(2,2,1), imagesc(x,y,C)
x = linspace(size(C, 2), 1, numel(x)); % reverse only x
set(gca, 'XTick', x, 'XTickLabel', x)
subplot(2,2,2), imagesc(x,y,C2)
x = linspace(1, size(C, 2), numel(x)); % reverse back x
set(gca, 'XTick', x, 'XTickLabel', x)
y = linspace(size(C, 1), 1, numel(y)); % reverse y
set(gca, 'YTick', y, 'YTickLabel', flipud(y(:)))
subplot(2,2,3), imagesc(x,y,C3)
x = linspace(size(C, 2), 1, numel(x)); % now both x,y reversed
set(gca, 'XTick', x, 'XTickLabel', x)
y = linspace(1, size(C, 1), numel(y)); % reverse y
set(gca, 'YTick', y, 'YTickLabel', flipud(y(:)))
subplot(2,2,4), imagesc(x,y,C4)
Resultado
Error using matlab.graphics.axis.Axes/set
While setting the 'XTick' property of 'Axes':
Value must be a vector of type single or double whose values increase
Error in test_imagesc_subplot_figure (line 26)
set(gca, 'XTick', x, 'XTickLabel', x)
Proposta de EskappEu faço sem sucesso o seguinte, mas nenhuma alteração na Fig. 2; a primeira linha de figuras permanece na mesma ordem crescente dexaxis
; Eu também tentei em vez dereverse
- normal
figure
subplot(2,2,1), imagesc(x,y,C)
x = linspace(1, size(C, 2), numel(x)); % reverse only x
set(gca,'xdir','reverse')
subplot(2,2,2), imagesc(x,y,C2)
Saída da Fig. 1 e Fig. 2axis
continue o mesmo
Saída na etiqueta do eixo y ao usarset(gca,'XTick',x,'XTickLabel',x, 'YTick',y,'YTickLabel',fliplr(y))
com variáveisy=linspace(0,180,181); x=0:0.5:10
Matlab: 2016a
SO: Debian 8.5 de 64 bits
Hardware: Asus Zenbook UX303UA