Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
axis labels

Subject: axis labels

From: someone else

Date: 23 Apr, 2013 13:15:07

Message: 1 of 2

Hi,

I want to have horizontal y axes labels to subplots. I try to place them so they don't overlap with the axes. Small example:

subplot(2,1,1);
plot(rand(10,1));
h = zeros(2,1);
h(1) = ylabel({'Short';'label'});
subplot(2,1,2);
plot(rand(10,1));
h(2) = ylabel({'This is a long';'label of y axis'});
set(h,'Rotation',0);

I believe controlling one or both of the two properties, 'position' and 'extent', could enable what I want. I know how to get them:

pos = get(h,'position');
ext = get(h,'extent');

but I'm not quite sure what their meaning is. I guess I should measure the width of all labels and then try to reposition them so they respect the longest one.

Maybe I also prefer to left-align the labels text.

Any help would be much appreciated!

Subject: axis labels

From: someone else

Date: 23 Apr, 2013 16:13:07

Message: 2 of 2

> but I'm not quite sure what their meaning is.

Please does someone know to explain or give examples to these questions... I don't quite see answers in the documentation nor web.

What do the "x and y" ext(1) and ext(2) relate to, figure dimensions (normalized to 1) or axes?

I guess ext(3) and ext(4) give the width and height of the "rectangle" inside of which is the axis label. Then no need to change these, given a font size I think. Right?

What do "x and y" pos(1) and (2) relate to, figure dimensions or axes?

I believe with a 2D-picture I don't need to care about the "z" pos(3). Correct?

Thanks a lot for any hints.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us