mat
mat

Reputation: 2617

Add space between plots for the plotmatrix function

Is there a way to add some space between the plots for the plotmatrix function? (I would like to label every x and y axis)

Upvotes: 0

Views: 278

Answers (1)

Benoit_11
Benoit_11

Reputation: 13945

You can do it by using a specific output argument in the call to plotmatrix. You can then retrieve the position of each individual axes and modify it (making it smaller).

Example:

clc
clear

rng default
X = randn(50,3);
Y = reshape(1:150,50,3);

%// Use this output argument
[~,AX,~,~,~] = plotmatrix(X,Y);

%// Fetch all the positions and alter them (make axes smaller)
AllPos = get(AX(:),'Position');

AllPos = vertcat(AllPos{:});

NewPos = [AllPos(:,1)+.05 AllPos(:,2)+.05 AllPos(:,3)-.1 AllPos(:,4)-.1]

%// Update the plot
for k = 1:numel(AX)
    axes(AX(k))

    set(AX(k),'Position',NewPos(k,:))

    xlabel(sprintf('Axes %i',k))

end

Outputs the following:

enter image description here

In contrast to the original plot:

enter image description here

Upvotes: 1

Related Questions