Setting default line widths for all plotting functions (2024)

207 views (last 30 days)

Show older comments

Roy Goodman on 16 Aug 2023

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/2009382-setting-default-line-widths-for-all-plotting-functions

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/2009382-setting-default-line-widths-for-all-plotting-functions

Edited: Adam Danz on 16 Aug 2023

Accepted Answer: Steven Lord

MATLAB's default linewidths are all too narrow for my taste. I have a startup.m file with many lines like

set(groot,'DefaultLineLineWidth',2)

set(groot,'DefaultContourLineWidth',1.5)

set(groot,'DefaultFunctionContourLineWidth',2)

Every time I learn about a new plot type, I have to add an additional line to my startup file. Today I needed to use fimplicit. So far, I haven't figured out what to set to fix this. This leads me to three questions.

  1. What's the line I need to add to my startup file?
  2. How would I reverse engineer this to find out without posting here?
  3. Is there a master linewidth that I could set which would set all line widths for all time, no matter what function was used to create them?
0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Steven Lord on 16 Aug 2023

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/2009382-setting-default-line-widths-for-all-plotting-functions#answer_1288557

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/2009382-setting-default-line-widths-for-all-plotting-functions#answer_1288557

Open in MATLAB Online

Looking at your second question first, if you look at the end of the fimplicit function's documentation page, there's a link to "ImplicitFunctionLine Properties". On that page, the value of the Type property is 'implicitfunctionline'. By the "Specify Default Values" section on this documentation page that means you should set the property:

P = "default" + "implicitfunctionline" + "LineWidth"

P = "defaultimplicitfunctionlineLineWidth"

This sort of implicitly answers your first question. Let's try it.

h = fimplicit(@(x,y) x.^2 - y.^2 - 1);

d = h.LineWidth % show the factory default

d = 0.5000

title("LineWidth of " + d)

Setting default line widths for all plotting functions (3)

set(groot, P, 10*d);

figure

h = fimplicit(@(x,y) x.^2 - y.^2 - 1);

d = h.LineWidth % show the factory default

d = 5

title("LineWidth of " + d + " after changing default")

Setting default line widths for all plotting functions (4)

For your third question I believe the answer is no. However, if you're okay with changing the properties of all objects with a LineWidth property after the fact, you could use the findall or findobj functions and ask for all objects that have a LineWidth.

h = findall(groot, ... % All graphics objects that are "descendants" of groot (i.e. all of them)

'-property', 'LineWidth') % that possess a LineWidth property

h =

6×1 graphics array: Axes (LineWidth of 5 after changing default) Axes (LineWidth of 0.5) ImplicitFunctionLine Text (LineWidth of 5 after changing default) ImplicitFunctionLine Text (LineWidth of 0.5)

Note that in addition to the lines created by fimplicit h lists two axes (which the axes properties page states controls "Line width of axes outline, tick marks, and grid lines, specified as a positive numeric value in point units. One point equals 1/72 inch.") and two text objects (the titles, for which the text properties page says the LineWidth property controls "Width of box outline, specified as a scalar numeric value in point units. One point equals 1/72 inch.")

So let's look at what would happen if you changed all those LineWidths to something much larger. It might not look exactly as you want, since the axes has a LineWidth.

f = figure;

h = fimplicit(@(x,y) x.^2 - y.^2 - 1);

t = title('Example');

titleLineWidthBefore = t.LineWidth

titleLineWidthBefore = 0.5000

hasLineWidth = findall(f, '-property', 'LineWidth')

hasLineWidth =

3×1 graphics array: Axes (Example) ImplicitFunctionLine Text (Example)

set(hasLineWidth, 'LineWidth', 10)

Setting default line widths for all plotting functions (5)

The LineWidth change did affect the text object returned by title, but since that object's EdgeColor is 'none' we don't see any visible change.

t.EdgeColor

ans = 'none'

titleLineWidthAfter = t.LineWidth

titleLineWidthAfter = 10

1 Comment

Show -1 older commentsHide -1 older comments

Roy Goodman on 16 Aug 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2009382-setting-default-line-widths-for-all-plotting-functions#comment_2851857

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2009382-setting-default-line-widths-for-all-plotting-functions#comment_2851857

This answer is thorough beyond any expectation. Thanks.

Sign in to comment.

More Answers (1)

Adam Danz on 16 Aug 2023

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/2009382-setting-default-line-widths-for-all-plotting-functions#answer_1288567

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/2009382-setting-default-line-widths-for-all-plotting-functions#answer_1288567

Edited: Adam Danz on 16 Aug 2023

Open in MATLAB Online

This issues comes up from time to time. As @Steven Lord mentioned, there is no global setting that would apply to all LineWidth properties.

Here's an alternative approach inspired by the work of another user who recently faced this problem. I've generalized and slightly improved the solution below.

It makes the following assumptions

  1. All LineWidth properties will be listed in the groot factory list
  2. All LineWidth properties can be identified as ending in "LineWidth" as Steven Lord explained.
  3. All factory properties ending in LineWidth affect the LineWidth property of an object and can accept a value of 1.
  4. All LineWidth factory properties can be converted to default property names

This was tested in R2023a which lists 46 linewidth names

% List all factory properties

factoryNames = fieldnames(get(groot,'factory'));

% Identify and extract the factory properties that end with "LineWidth"

factoryLineWidthIndex = endsWith(factoryNames,'LineWidth');

factoryLineWidthNames = factoryNames(factoryLineWidthIndex)

factoryLineWidthNames = 46×1 cell array

{'factoryAnimatedlineLineWidth' } {'factoryAreaLineWidth' } {'factoryArrowshapeLineWidth' } {'factoryAxesGridLineWidth' } {'factoryAxesLineWidth' } {'factoryAxesMinorGridLineWidth' } {'factoryBarLineWidth' } {'factoryBubblechartLineWidth' } {'factoryBubblelegendLineWidth' } {'factoryCategoricalhistogramLineWidth' } {'factoryColorbarLineWidth' } {'factoryConstantlineLineWidth' } {'factoryConstantregionLineWidth' } {'factoryContourLineWidth' } {'factoryDoubleendarrowshapeLineWidth' } {'factoryEllipseshapeLineWidth' } {'factoryErrorbarLineWidth' } {'factoryFunctioncontourLineWidth' } {'factoryFunctionlineLineWidth' } {'factoryFunctionsurfaceLineWidth' } {'factoryGeoaxesLineWidth' } {'factoryGraphplotLineWidth' } {'factoryHistogram2LineWidth' } {'factoryHistogramLineWidth' } {'factoryImplicitfunctionlineLineWidth' } {'factoryImplicitfunctionsurfaceLineWidth'} {'factoryLegendLineWidth' } {'factoryLineLineWidth' } {'factoryLineshapeLineWidth' } {'factoryMapaxesGraticuleLineWidth' }

% Convert the factory property list to default property names

defaultLineWidthNames = regexprep(factoryLineWidthNames,'^factory','default')

defaultLineWidthNames = 46×1 cell array

{'defaultAnimatedlineLineWidth' } {'defaultAreaLineWidth' } {'defaultArrowshapeLineWidth' } {'defaultAxesGridLineWidth' } {'defaultAxesLineWidth' } {'defaultAxesMinorGridLineWidth' } {'defaultBarLineWidth' } {'defaultBubblechartLineWidth' } {'defaultBubblelegendLineWidth' } {'defaultCategoricalhistogramLineWidth' } {'defaultColorbarLineWidth' } {'defaultConstantlineLineWidth' } {'defaultConstantregionLineWidth' } {'defaultContourLineWidth' } {'defaultDoubleendarrowshapeLineWidth' } {'defaultEllipseshapeLineWidth' } {'defaultErrorbarLineWidth' } {'defaultFunctioncontourLineWidth' } {'defaultFunctionlineLineWidth' } {'defaultFunctionsurfaceLineWidth' } {'defaultGeoaxesLineWidth' } {'defaultGraphplotLineWidth' } {'defaultHistogram2LineWidth' } {'defaultHistogramLineWidth' } {'defaultImplicitfunctionlineLineWidth' } {'defaultImplicitfunctionsurfaceLineWidth'} {'defaultLegendLineWidth' } {'defaultLineLineWidth' } {'defaultLineshapeLineWidth' } {'defaultMapaxesGraticuleLineWidth' }

% Loop through the default line width names and set their value to 1

for i = 1:numel(defaultLineWidthNames)

set(groot,defaultLineWidthNames{i},1)

end

Test it

fig = figure();

ax = axes();

hold on

h = plot([1,2]);

xl = xline(1.5);

cb = colorbar();

h.LineWidth

ans = 1

xl.LineWidth

ans = 1

cb.LineWidth

ans = 1

ax.LineWidth

ans = 1

close(fig)

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABGraphicsGraphics ObjectsGraphics Object Identification

Find more on Graphics Object Identification in Help Center and File Exchange

Tags

  • plotting
  • startup

Products

  • MATLAB

Release

R2023a

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.


Setting default line widths for all plotting functions (8)

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

Setting default line widths for all plotting functions (2024)

References

Top Articles
Red Hot Chili Peppers Drummer Chad Smith: Everything You Need To Know - Drumeo Beat
Gotrax Hoverboard Manual
Nene25 Sports
Jeff Bezos Lpsg
Https //Paperlesspay.talx.com/Gpi
What to Do For Dog Upset Stomach
Eric Rohan Justin Obituary
Episode 163 – Succession and Legacy • History of the Germans Podcast
Boomerang Uk Screen Bug
Guardians Of The Galaxy Showtimes Near Athol Cinemas 8
Ark Ragnarok Map Caves
Registrar Utd
Thothub Alinity
Sunshine999
Round Yellow Adderall
How do you evaluate cash flow?
Is Holly Warlick Married To Susan Patton
Weather Channel Quincy
Megan Thee Stallion, Torrey Craig Seemingly Confirm Relationship With First Public Outing
Yovanis Pizzeria - View Menu & Order Online - 741 NY-211 East, Middletown, NY 10941 - Slice
Soorten wolken - Weerbericht, weerhistorie, vakantieweer en veel weereducatie.
Las Mejores Tiendas Online en Estados Unidos - Aerobox Argentina
Nearest Walmart Address
Julie Green Ministries International On Rumble
Tyrone Unblocked Games Bitlife
Zillow Group, Inc. Aktie (A14NX6) - Kurs Nasdaq - MarketScreener
Omniplex Cinema Dublin - Rathmines | Cinema Listings
Craigslist Swm
Joy Ride 2023 Showtimes Near Cinemark Huber Heights 16
Busted Paper Haysi Regional Jail
Oscillates Like A Ship
How Old Am I 1981
Vip Market Vetsource
Tnt Tony Superfantastic
Visit Lake Oswego! - Lake Oswego Chamber Of Commerce
Meet Kristine Saryan, Scott Patterson’s Wife
Distance To Indianapolis
Did Taylor Swift Date Greg Gutfeld
Ups Access Point Location Hamburg Photos
Solve x^2+2x-24=0 | Microsoft Math Solver
Curaleaf Announces Majority Stake and Forms Strategic Partnership with Germany's Four 20 Pharma, a Fully EU-GMP & GDP Licensed Producer and Distributor of Medical Cannabis
Www.craiglist.com San Antonio
Fuzz Bugs Factory Number Bonds
Splunk Stats Count By Hour
Fineassarri
Exposedrealfun Collage
Atlanta Farm And Garden By Owner
Poopybarbz
Six Broadway Wiki
Used Go Karts For Sale Near Me Craigslist
Auctionzipauctions
Latest Posts
Article information

Author: Otha Schamberger

Last Updated:

Views: 6665

Rating: 4.4 / 5 (55 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Otha Schamberger

Birthday: 1999-08-15

Address: Suite 490 606 Hammes Ferry, Carterhaven, IL 62290

Phone: +8557035444877

Job: Forward IT Agent

Hobby: Fishing, Flying, Jewelry making, Digital arts, Sand art, Parkour, tabletop games

Introduction: My name is Otha Schamberger, I am a vast, good, healthy, cheerful, energetic, gorgeous, magnificent person who loves writing and wants to share my knowledge and understanding with you.