How do I plot lines with different line widths? (2024)

5.682 Ansichten (letzte 30 Tage)

Ältere Kommentare anzeigen

Leor Greenberger am 22 Sep. 2011

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths

Beantwortet: SHAILENDRA PANDEY am 11 Okt. 2020

Akzeptierte Antwort: Fangjun Jiang

In MATLAB Online öffnen

Hi,

I want to do:

plot(x1,y1,x2,y2,'LineWidth',8)

but the linewidth propery ends up applying to both lines. Do I have to use two plot functions with a hold on command to have line1 a different width than line2? Thanks.

2 Kommentare

Keine anzeigenKeine ausblenden

Jagannadh Kumar am 8 Mär. 2016

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#comment_348787

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#comment_348787

Try writing like this plot(x1,y1,'Linewidth',6,x2,y2,'Linewidth',8)

Ramesh M am 28 Jul. 2016

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#comment_382048

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#comment_382048

it works thnx

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Akzeptierte Antwort

Fangjun Jiang am 22 Sep. 2011

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#answer_22266

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#answer_22266

Bearbeitet: MathWorks Support Team am 8 Nov. 2018

In MATLAB Online öffnen

To plot two lines with different line widths, you can use either of these approaches.

1. Return the two “Line” objects as an output argument from the “plot” function and then set the “LineWidth” property for each.

p = plot(x1,y1,x2,y2)

p(1).LineWidth = 5;

p(2).LineWidth = 10;

2. Use the “hold on” command to plot the two lines separately. Specify the line width by setting the “LineWidth” property a name-value pair.

plot(x1,y1,'LineWidth',5)

hold on

plot(x2,y2,'LineWidth',10)

hold off

2 Kommentare

Keine anzeigenKeine ausblenden

Tyler Tomlinson am 2 Dez. 2015

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#comment_326933

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#comment_326933

Thank you that worked great.

Mike Garrity am 8 Mär. 2016

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#comment_348799

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#comment_348799

In MATLAB Online öffnen

Just FYI, there is an "official" syntax for setting a property to different values on different objects. However, it's really ugly, and doesn't work everywhere. For example, I don't think that the plot function accepts this form.

It looks like this:

h = plot(x1,y1,x2,y2);

set(h,{'LineWidth'},{5;10})

The property name and property value need to each be a cell array, and the shape of the value cell array has to match the shape of the handle cell array.

That said, you're really better off with 2 calls to set in this case.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

Wayne King am 22 Sep. 2011

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#answer_22267

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#answer_22267

In MATLAB Online öffnen

Hi: You can use handles.

h = plot(x1,y1,x2,y2);

set(h(1),'linewidth',1);

set(h(2),'linewidth',2);

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Hari Desanur am 15 Nov. 2016

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#answer_243422

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#answer_243422

Bearbeitet: Hari Desanur am 15 Nov. 2016

In MATLAB Online öffnen

The line width for a particular line can be set using line object handles. For example -

l = plot(x1,y1,x2,y2);

l(1).LineWidth = 3; % set line width of 3 for the first line (x1,y1)

l(2).LineWidth = 6;

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

SHAILENDRA PANDEY am 11 Okt. 2020

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#answer_510681

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/16477-how-do-i-plot-lines-with-different-line-widths#answer_510681

In MATLAB Online öffnen

x = 1:.01:10;

y1 = sin(x);

y2 = cos(x);

p = plot(x,y1,x,y2)

set(p,{'LineWidth'},{5;10})

Line width, specified as a positive value in points, where 1 point = 1/72 of an inch. If the line has markers, then the line width also affects the marker edges.

The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Siehe auch

Kategorien

MATLABGraphicsFormatting and Annotation

Mehr zu Formatting and Annotation finden Sie in Help Center und File Exchange

Tags

  • plot linewidth
  • cheat sheets

Community Treasure Hunt

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

Start Hunting!

Es ist ein Fehler aufgetreten

Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.


Translated by How do I plot lines with different line widths? (10)

How do I plot lines with different line widths? (11)

Website auswählen

Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .

Sie können auch eine Website aus der folgenden Liste auswählen:

Amerika

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

Europa

  • 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)

Asien-Pazifik

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

Kontakt zu Ihrer lokalen Niederlassung

How do I plot lines with different line widths? (2024)

FAQs

How do I change the LineWidth of a plot in MATLAB? ›

Accepted Answer

You can set the default MATLAB linewidth property by setting the 'DefaultLineLineWidth' property of the root graphics object. When new lines are created, they will inherit this property from the root object.

What is the width of the line in MATLAB plot? ›

By default, the line width size is '1' in Matlab. Sometimes in complex figures or diagrams output gets disturbed or vanish, in such cases line width plays an important role. This command is represented as 'LineWidth'.

How to change the width of a plot in MATLAB? ›

plot(X_a,Y_a,'LineWidth',10);

How do you thicken lines in MATLAB plot? ›

Modify Line Width, Marker Fill, and Marker Outline

For example, Line objects have a LineWidth property for controlling the line's thickness. To create a thicker line, you can specify the LineWidth as a name-value argument when you call the plot function. In this case, set the LineWidth to 3 .

How do you change the width of the line plot in Matplotlib? ›

You can use the keyword argument linewidth or the shorter lw to change the width of the line.

What is LineWidth in plot? ›

Line width in the Matplot library is simply the size of the line of plot.

How do you change the width of a graph? ›

To change the size manually, click the chart, and then drag the sizing handles to the size that you want. To use specific height and width measurements, on the Format tab, in the Size group, enter the size in the Height and Width box. . Then in the Scale Height and Scale Width boxes, enter the numbers that you want.

How do you increase the width of a plot? ›

Adjusting Plot Size with figure()

To adjust the size of this canvas, you can use the figure() function, which allows you to specify the width and height of the figure in inches. In the above code, figsize=(10, 5) sets the size of the plot to 10 inches wide and 5 inches tall.

How to control the size of a plot in MATLAB? ›

To change the size of the plotting area, specify this property as a vector of the form [left bottom width height] . Use this function to query the plotting area, which is typically bounded by the plot box.

How do I change the thickness of a line in a plot in R? ›

Adjust the R line thickness by specifying the options lwd (base plot) and size (ggplot2). Change manually the appearance (linetype, color and size) of ggplot lines by using, respectively, the function scale_linetype_manual(), scale_color_manual() and scale_size_manual().

How do I change line spacing in MATLAB? ›

To change the line spacing option, do one of the following:
  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Command Window, and then choose a Line spacing option.
  2. Use the format function at the command line, for example: format loose format compact.

How do you increase the thickness of a line in a plot in Python? ›

You can also change the line width by passing a linewidth parameter to the plt. plot() function. The linewidth parameter takes a floating-point value representing the line's width.

How to change LineWidth of step response in MATLAB? ›

Direct link to this answer
  1. In the figure window select the Edit Plot option from toolbaar.
  2. Then select and right-click on the elements like line aur marker whose property you want to change.
  3. Open property inspector: You can see the related properties like LineWidth and MarkerSize.
  4. Finally, change the values.
Mar 31, 2020

What is the default LineWidth of a plot in MATLAB? ›

  • d = h.LineWidth % show the factory default. d = 0.5000.
  • title("LineWidth of " + d)
  • d = h.LineWidth % show the factory default. d = 5.
  • title("LineWidth of " + d + " after changing default")
Aug 16, 2023

What is the default LineWidth of a plot in Matplotlib? ›

If you want to reset the default linewidth to its original value, you can simply set it back to the default value of 1.

Top Articles
Garry Kasparov, despre alegerile din SUA: „Este o ruşine că două partide majore au putut oferi o asem*nea opţiune” - Dambovitadeazi.ro
Jonathan Taylor Children, Career, and Net Worth
2022 Basketball 247
ALLEN 'CHAINSAW' KESSLER | LAS VEGAS, NV, United States
Craigslist The Big Island
Best Internists In Ft-Lauderdale
Uta Kinesiology Advising
15 Cloud Tattoo Meaning Symbolism- Reflecting Change and Transience
Select Walgreens Stores: Lasko 16" Stand Fan $7.50 & More + Free Store Pickup on $10+
Mets Game Highlights
Weldmotor Vehicle.com
Uta Frontrunner Twitter
Pokemon Infinite Fusion Good Rod
Things to do in Wichita Falls this weekend Sept. 12-15
Websites erstellen, benennen, kopieren oder löschen
The Center Breakfast, Lunch & Snack Menus September 2024
NEU: LEAKSHIELD - das sicherste Flüssigkeits-Kühlsystem der Welt - Wasserkühlung
The Perfect Couple Episode 5 Cast & Characters - Eve Hewson, Nicole Kidman & More (Photos)
Ruc Usmc List
Huniepop Jessie Questions And Answers
24 Hour Pharmacy St Louis Mo
How Much Is Felipe Valls Worth
Google Flights Msp To Fort Myers
Craigslist Quad Cities
Osrs Toby
Christmas Song Figgerits
The Ultimate Guide To Beautiful Spokane, Washington
Arkansas Craigslist Cars For Sale By Owner
Loss Payee And Lienholder Addresses And Contact Information Updated Daily Free List Bank Of America
Find Words Containing Specific Letters | WordFinder®
Maintenance Required Gear Selector Ecu
Clash of Clans: Best Hero Equipment For The Archer Queen, Ranked
Restaurants Near Defy Trampoline Park
Sweeterthanolives
St Cloud Rants And Raves
Tulare Lake’s ghostly rebirth brings wonder — and hardship. Inside a community's resilience
Top Compact Cars for 2025: Consumer Reports, Safety, and Overall Value Ratings
Jcpenney Salon Salinas
Stony Brook Citrix Login
Fuzz Bugs Factory Hop Halloween
Avalon Hope Joi
Viewfinder Mangabuddy
Open The Excel Workbook Revenue.xls From The Default Directory
Prodigy Login For Students
Obtaining __________ Is A Major And Critical Closure Activity.
Drew Gulliver Bj
Fast X Showtimes Near Regal Spartan
Farmers And Merchants Bank Broadway Va
Schedule360 Minuteclinic
Dark Pictures Wiki
Classic Forbidden Romance: 6 Reasons To Watch C-Drama “Love Between Fairy And Devil”
What stores are open on Labor Day 2024? A full list of where to shop
Latest Posts
Article information

Author: Dan Stracke

Last Updated:

Views: 6028

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Dan Stracke

Birthday: 1992-08-25

Address: 2253 Brown Springs, East Alla, OH 38634-0309

Phone: +398735162064

Job: Investor Government Associate

Hobby: Shopping, LARPing, Scrapbooking, Surfing, Slacklining, Dance, Glassblowing

Introduction: My name is Dan Stracke, I am a homely, gleaming, glamorous, inquisitive, homely, gorgeous, light person who loves writing and wants to share my knowledge and understanding with you.