Is there a setting to move labels on a plot closer (2024)

27 views (last 30 days)

Show older comments

Zhangxi Feng on 22 Aug 2024 at 21:29

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer

Commented: Zhangxi Feng on 22 Aug 2024 at 22:28

Accepted Answer: Matt J

  • data.mat

Open in MATLAB Online

In the following image is plotted with the code:

load('data.mat');

f = figure;

f.Position = [21,471,1883,333];

subplot(1,4,1);

S = 50;

scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd1,'filled');

xlabel('x (\mum)');

ylabel('y (\mum)');

zlabel('z (\mum)');

xlim([-15 15]);

ylim([-15 15]);

zlim([-15 15]);

xticks([-15 0 15]);

xticklabels({'-15','0','15'});

yticks([-15 0 15]);

yticklabels({'-15','0','15'});

zticks([-15 0 15]);

zticklabels({'-15','0','15'});

% axis equal;

cb = colorbar();

% clim([0 1]);

title(cb, 'SD1');

subplot(1,4,2);

S = 50;

scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd2,'filled');

xlabel('x (\mum)');

ylabel('y (\mum)');

zlabel('z (\mum)');

xlim([-15 15]);

ylim([-15 15]);

zlim([-15 15]);

xticks([-15 0 15]);

xticklabels({'-15','0','15'});

yticks([-15 0 15]);

yticklabels({'-15','0','15'});

zticks([-15 0 15]);

zticklabels({'-15','0','15'});

% axis equal;

cb = colorbar();

% clim([0 1]);

subplot(1,4,3);

S = 50;

scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd3,'filled');

xlabel('x (\mum)');

ylabel('y (\mum)');

zlabel('z (\mum)');

xlim([-15 15]);

ylim([-15 15]);

zlim([-15 15]);

xticks([-15 0 15]);

xticklabels({'-15','0','15'});

yticks([-15 0 15]);

yticklabels({'-15','0','15'});

zticks([-15 0 15]);

zticklabels({'-15','0','15'});

% axis equal;

cb = colorbar();

% clim([0 1]);

title(cb, 'SD3');

subplot(1,4,4);

S = 50;

scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,relangle,'filled');

xlabel('x (\mum)');

ylabel('y (\mum)');

zlabel('z (\mum)');

xlim([-15 15]);

ylim([-15 15]);

zlim([-15 15]);

xticks([-15 0 15]);

xticklabels({'-15','0','15'});

yticks([-15 0 15]);

yticklabels({'-15','0','15'});

zticks([-15 0 15]);

zticklabels({'-15','0','15'});

% axis equal;

cb = colorbar();

clim([0 30]);

title(cb, '\alpha');

Notice the colorbar labels "SD1", "SD2", "SD3" are clipped at the top and X and Y axes labels are far away from the axes.

Is there a setting to fix all these? I have been moving them manually with the editor but I have several of these figures and would like to make them as consistent as possible in terms of things like label positions. I think it is possible to scan the texts and set their positions semi-manually with code, but it would be much easier if there is a setting like "tight' or something to move them closer. But "axis tight" does not work here, possibly due to the 3D nature of the plots.

Is there a setting to move labels on a plot closer (2)

3 Comments

Show 1 older commentHide 1 older comment

Zhangxi Feng on 22 Aug 2024 at 21:38

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244269

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244269

For reference, I would like for it to look like this:

Is there a setting to move labels on a plot closer (4)

Matt J on 22 Aug 2024 at 22:04

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244304

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244304

Edited: Matt J on 22 Aug 2024 at 22:05

Your code doesn't run, because the arguments to scatter3() are not provided.

Zhangxi Feng on 22 Aug 2024 at 22:15

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244324

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244324

I didn't feel like being able to plot was important. I have now attached the data.mat file and added load('data.mat') to the code.

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Matt J on 22 Aug 2024 at 22:12

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#answer_1503734

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#answer_1503734

Edited: Matt J on 22 Aug 2024 at 22:14

Open in MATLAB Online

You can use the axis label text object porperties to move them around, e.g.,

h=gca;

h.XLabel.Position(end)=h.XLabel.Position(end)+0.1

and the axes OuterPosition property to shrink the height of the axes and prevent the clipping, e.g.,

h.OuterPosition(end)=h.OuterPosition(end)*0.9

3 Comments

Show 1 older commentHide 1 older comment

Zhangxi Feng on 22 Aug 2024 at 22:16

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244329

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244329

Edited: Zhangxi Feng on 22 Aug 2024 at 22:17

Right, so that's the only option then? This is not ideal since these are 3D plots and I would need to manipulate 3D position I believe. Manually editing the plot might be faster

Matt J on 22 Aug 2024 at 22:26

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244339

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244339

Open in MATLAB Online

This is not ideal since these are 3D plots and I would need to manipulate 3D position I believe

I'm not sure why that is "not ideal", but it is not necessary in any case. You can specify the label positions with 2D coordinates if you wish, even in 3D plots, e.g.,

scatter3(rand,rand,rand);

xlabel 'X-axis'; ylabel 'Y-Axis'; zlabel 'Z-Axis';

h=gca;

h.XLabel.Position=[h.XLabel.Position(1:2)]+[0,0.3];

Is there a setting to move labels on a plot closer (10)

Zhangxi Feng on 22 Aug 2024 at 22:28

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244344

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2147374-is-there-a-setting-to-move-labels-on-a-plot-closer#comment_3244344

Thanks this helps!

Sign in to comment.

More Answers (0)

Sign in to answer this question.

See Also

Tags

  • plotting
  • text
  • position

Products

  • MATLAB

Release

R2023b

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Is there a setting to move labels on a plot closer (12)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

Is there a setting to move labels on a plot closer (2024)

References

Top Articles
Shane Gillis Net Worth Projected For 2024: Unlocking Financial Success
Ashanti's Enormous Net Worth: Unlocking Her Financial Success In 2024 According To Forbes
Menards Thermal Fuse
Cars & Trucks - By Owner near Kissimmee, FL - craigslist
Myexperience Login Northwell
Lycoming County Docket Sheets
Housing Intranet Unt
What Does Dwb Mean In Instagram
Weekly Math Review Q4 3
World History Kazwire
Blue Beetle Showtimes Near Regal Swamp Fox
David Turner Evangelist Net Worth
Funny Marco Birth Chart
Kris Carolla Obituary
Lesson 8 Skills Practice Solve Two-Step Inequalities Answer Key
Conan Exiles Colored Crystal
Dutch Bros San Angelo Tx
Plan Z - Nazi Shipbuilding Plans
Booknet.com Contract Marriage 2
MLB power rankings: Red-hot Chicago Cubs power into September, NL wild-card race
Toothio Login
Strange World Showtimes Near Savoy 16
Roanoke Skipthegames Com
What Is a Yurt Tent?
Is Poke Healthy? Benefits, Risks, and Tips
Where to eat: the 50 best restaurants in Freiburg im Breisgau
Busch Gardens Wait Times
Helpers Needed At Once Bug Fables
Die wichtigsten E-Nummern
What Is Opm1 Treas 310 Deposit
Donald Trump Assassination Gold Coin JD Vance USA Flag President FIGHT CIA FBI • $11.73
Human Unitec International Inc (HMNU) Stock Price History Chart & Technical Analysis Graph - TipRanks.com
Greencastle Railcam
Trebuchet Gizmo Answer Key
Frostbite Blaster
Exploring The Whimsical World Of JellybeansBrains Only
Federal Student Aid
Top-ranked Wisconsin beats Marquette in front of record volleyball crowd at Fiserv Forum. What we learned.
Bitchinbubba Face
Robeson County Mugshots 2022
M Life Insider
Gopher Hockey Forum
Torrid Rn Number Lookup
How to Connect Jabra Earbuds to an iPhone | Decortweaks
877-552-2666
Learn4Good Job Posting
40X100 Barndominium Floor Plans With Shop
El Patron Menu Bardstown Ky
Runescape Death Guard
Metra Union Pacific West Schedule
Att Corporate Store Location
Island Vibes Cafe Exeter Nh
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 5473

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.