Suzan Cioc
Suzan Cioc

Reputation: 30147

How to position axes from top of the figure in Matlab?

When I issue the following command

>> figure; axes('Units','pixels','Position',[0,0,100,100])

I get small 100x100 axes object at the left bottom corner of a figure.

The size of the axes remains constant and it also remains docked to the same corner if figure resize.

How to do the same with upper left corner?

Upvotes: 2

Views: 1749

Answers (1)

Colorless Photon
Colorless Photon

Reputation: 399

If you want to set the origin to the upper left corner you can set the attributes xaxislocation to top and yaxislocation to left. Further you can mention that y coords should increase from top to bottom by setting ydir to reverse.

To make sure the size of the axes is maintained set attribute ActivePositionProperty to Position.

So at the end your command will look something like:

figure;axes('Units','pixels','Position', [10,200,100,100],'xaxislocation','top','yaxislocation','left','ydir','reverse','ActivePositionProperty','Position')

Note that in the figure obtained origin is at the upper left corner of the axes not that of the window.

Upvotes: 1

Related Questions