1
votes

I'm producing a figure in MATLAB that consists of a grid of subplots, each of which contains a polar plot. I would like to label this grid by row and column.

Column labels are easy, using the title text for each plot.

For row labels, with Cartesian plots I'd simply abuse the y-axis labels of the first column of subplots, but with polar plots there is (reasonably) no ylabel. How can I add row labels?

Note that I am using the new polarplot() function that was introduced in MATLAB 2016a, so most existing answers out there that refer to polar() do not apply.

1
I want one y-label per row of subplots (i.e. it's a label for that row) - Flyto

1 Answers

2
votes

It's pretty hacky, but if you really want, you could create the ylabels in a temporary axes, copy them over to the polarplots, and then get rid of the temporary axes.

Example:

% Setup some polarplots
m=2;n=3;        % Number of plots to make
padding = 0.5;  % Determines space between labels and plots
atmp=axes;
figure;
for j=1:m
    for k=1:n
        subplot(m,n,sub2ind([n,m],k,j));       
        polarplot(0);

        % Add labels
        if j==1 % Top labels
            htmp=xlabel(atmp, 'Top Label');
            htmp.Units='normalized';
            htmp.Position(2)= 1+padding;
            copyobj(htmp,gca);
        end
        if k==1 % Left Labels
            htmp=ylabel(atmp, 'Left Label');
            htmp.Units='normalized';
            htmp.Position(1)= -padding;
            copyobj(htmp,gca);
        end
    end
end
close(atmp.Parent); % Close the temporary axes

Which creates:

image of subplots with labels