2012-04-30 26 views

risposta

6

caso di una matrice n x n correlazione M, e un vettore L di lunghezza n contenente l'etichetta per ciascun intervallo, si può usare qualcosa come i seguenti:

imagesc(M); % plot the matrix 
set(gca, 'XTick', 1:n); % center x-axis ticks on bins 
set(gca, 'YTick', 1:n); % center y-axis ticks on bins 
set(gca, 'XTickLabel', L); % set x-axis labels 
set(gca, 'YTickLabel', L); % set y-axis labels 
title('Your Title Here', 'FontSize', 14); % set title 
colormap('jet'); % set the colorscheme 
colorbar on; % enable colorbar 

rotante etichette di asse x non è banale , ma MATLAB Central File Exchange contiene some solutions.

+0

Per la rotazione dell'etichetta dell'asse x, è possibile farlo facilmente tramite la finestra delle figure MATLAB: 1. selezionare * Mostra strumenti di stampa e figure di ancoraggio * pulsante dalla barra degli strumenti, https: //i.stack .imgur.com/lmiz1.png 2. fai clic sulle etichette dell'asse x sulla figura https://i.stack.imgur.com/63oKg.png 3. scegli * più propertises ... * dalla finestra visualizzata https://i.stack.imgur.com/o8NRm.png 4. Passare a * XTickLabelRotation * e impostarlo su 90.0 https://i.stack.imgur.com/FHjz7.png – user1323163

1

per tracciare una matrice come immagine basta chiamare due funzioni:

image(myMatrix) 
colormap(jet) 

La funzione colormap definisce il modello di colore usato per rendere l'immagine. L'immagine che hai postato utilizza la mappa colori "jet".

E per visualizzare la scala dei colori accanto all'immagine utilizzare la funzione colorbar.

2

aggiunta alla risposta di @Thomas C. G., userei:

imagesc(myMatrix); 
colormap(jet); 
colorbar; 

% then to set the axis titles you'll have to use 
% Please note the curly braces for the cell array 
labelNames = {'USA','NASDAQ','Dow Jones'}; 
set(gca,'XTickLabel',labelNames); % gca gets the current axis 
set(gca,'YTickLabel'labelNames); % gca gets the current axis 

Purtroppo, per quanto ne so, rendendo il testo etichette verticali come sono nella tua figura is a bit harder. Forse qualcun altro ha conoscenza contraria.

Problemi correlati