6.888 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Leor Greenberger am 22 Sep. 2011
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
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
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
⋮
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
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
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
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
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
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
-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
Melden Sie sich an, um zu kommentieren.
Hari Desanur am 15 Nov. 2016
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
-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
Melden Sie sich an, um zu kommentieren.
SHAILENDRA PANDEY am 11 Okt. 2020
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
-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.
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