How to reduce space between ylabel and y ticks in Matlab plot?

61 views (last 30 days)
How to reduce the space between y-label and y-ticks, in other words how to closer the y-label to y-axis.

Accepted Answer

Subhodh Sharma
Subhodh Sharma on 25 Sep 2021
Edited: Subhodh Sharma on 25 Sep 2021
You can use the below command..
ylh=ylabel('ylabel'); % adding ylabelto figure
ylh.Position(1)=ylh.Position(1)-dy; % you can change 'dy' according to your need. dy=+ve, will move the label from y axis. dy=-ve , will move the label closer to the axis.

Sign in to comment.

More Answers (1)

yanqi liu
yanqi liu on 26 Sep 2021
Edited: Walter Roberson on 26 Sep 2021
sir, my be you can ref the follow code, please check
clc; clear all; close all;
hs = get(gca, 'XLabel');
pos = get(hs, 'Position');
pos(2) = pos(2)+0.2;
set(hs, 'Position', pos)
hs = get(gca, 'YLabel');
pos = get(hs, 'Position');
pos(1) = pos(1)+0.2;
set(hs, 'Position', pos)
Ammy on 27 Sep 2021
Thank you very much, but its work for ezplot,
I want to do it for plot(x,y,..)
How can I use above for that?

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!