Add label to sub-axes in plotmatrix

47 次查看(过去 30 天)
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!!

采纳的回答

Isabel Chen
Isabel Chen 2015-3-20
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 个评论
Brendan
Brendan 2017-9-22
编辑:Brendan 2017-9-22
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 2024-2-15
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

请先登录,再进行评论。

更多回答(1 个)

Brendan
Brendan 2017-9-22
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 个评论
Nasrin
Nasrin 2020-3-2
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..

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by