Borrar filtros
Borrar filtros

Add label to sub-axes in plotmatrix

54 visualizaciones (últimos 30 días)
Isabel Chen
Isabel Chen el 15 de Mzo. de 2015
Comentada: Austin M. Weber el 15 de Feb. de 2024
I am using the plotmatrix function and would like to label the sub-axes (along the major Y axis and X axis only, of course). I've managed to turn all the YTickLabels and XTickLabels off:
set(AX,'YTickLabel',[]);
but cannot figure out how to change the current axes from BigAx to the required subaxes in AX. I can manually add the labels using plotTools, but there must be a way to do this using code? I have a large-ish matrix (10x10 minimum) so it would a real help to be able to write a script to do this. Please help!!

Respuesta aceptada

Isabel Chen
Isabel Chen el 20 de Mzo. de 2015
Just in case anyone is interested,
ylabel(AX(1,1),'str1')
ylabel(AX(2,1),'str2')
xlabel(AX(8,1),'str3')
xlabel(AX(8,2),'str4')
does the trick.
  2 comentarios
Brendan
Brendan el 22 de Sept. de 2017
Editada: Brendan el 22 de Sept. de 2017
The above suggestion doesn't work. This does.
X = randn(50,3);
Y = reshape(1:150,50,3);
[~,ax]=plotmatrix(X,Y);
ax(1,1).YLabel.String='Test1';
ax(2,1).YLabel.String='Test2';
ax(3,1).YLabel.String='Test3';
ax(3,1).XLabel.String='Test7';
ax(3,2).XLabel.String='Test8';
ax(3,3).XLabel.String='Test9';
Austin M. Weber
Austin M. Weber el 15 de Feb. de 2024
To save time, I recommend labeling the sub-axes programatically using a for-loop:
% Let's say you have the following data table
variable_names = {'Dog','Cat','Bird','Fish','Goat','Man','Bear','Pig'};
rng(0)
data_table = array2table(10.*randn(60,8)+50,'VariableNames',variable_names);
% Use plotmatrix to visualize the data and add axis labels with a for-loop
[~,ax] = plotmatrix(data_table{:,:});
iterations = size(ax,1);
for i = 1:iterations
ax(i,1).YLabel.String = variable_names(i);
ax(iterations,i).XLabel.String = variable_names(i);
end

Iniciar sesión para comentar.

Más respuestas (1)

Brendan
Brendan el 22 de Sept. de 2017
To create a sublabel on plotmatrix (on the outer subplots) use something like the following... The suggested answer above doesn't work.
X = randn(50,3);
Y = reshape(1:150,50,3);
[~,ax]=plotmatrix(X,Y);
ax(1,1).YLabel.String='Test1';
ax(2,1).YLabel.String='Test2';
ax(3,1).YLabel.String='Test3';
ax(3,1).XLabel.String='Test7';
ax(3,2).XLabel.String='Test8';
ax(3,3).XLabel.String='Test9';
  1 comentario
Nasrin
Nasrin el 2 de Mzo. de 2020
Thanks for sharing this code, I have a correlation plot with 14 variables.. I need to place all the lables.. but there is no enough space..
I've tested figure and label properties but they dont work..
How to modify this string type lables; for instance changing their orientation or font size..

Iniciar sesión para comentar.

Categorías

Más información sobre Labels and Annotations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by