How to change the line width for fplot?

조회 수: 605 (최근 30일)
Amit Kumar
Amit Kumar 2014년 5월 8일
댓글: 帅 赵 2021년 7월 11일
Hello All,
I want to make lines in graph thicker. Here is my code, but it seems not working.
clear all;
close all
clc;
w1=0;
w2=16.73;
x1= @(t) 0.05*cos(w1.*t)-0.05*cos(w2.*t);
x2= @(t) 0.05*cos(w1.*t)+0.05*cos(w2.*t);
graph1 = plot(figure1);
set(graph1,'LineWidth',2);
fplot(x1,[0,2],'k');
hold on;
fplot(x2,[0,2],'--k');
hold off;
legend('x','y');
title('plot');
xlabel('t');
ylabel('d');
I am increasing the linewidth, but messing up somewhere. In plot command, you can straightaway write 'LineWidth' in plot() itself, but no so in fplot. Any comments where I messed up?
  댓글 수: 1
Abby Skofield
Abby Skofield 2018년 10월 16일
Have you tried setting LineWidth directly in the call to fplot? Both plot and fplot support Name,Value pairs like LineWidth, as in:
x1= @(t) 0.05*cos(w1.*t)-0.05*cos(w2.*t);
fplot(x1,[0,2],'k','LineWidth',2);
hold on
plot(0:0.1:2,sin(0:0.1:2)/10,'k','LineWidth',2);

댓글을 달려면 로그인하십시오.

채택된 답변

lvn
lvn 2014년 5월 8일
편집: MathWorks Support Team 2018년 11월 27일
Starting in R2016a, you can specify the 'LineWidth' property the same way you do for plot. For example:
>> fplot(x1,[0,2],'k','LineWidth',2);
In R2015b and earlier releases, you have to search for the object and set the line width. To set the widths of all the lines to 2:
>> set(findall(gca, 'Type', 'Line'),'LineWidth',2);
Or, to set the width of one line:
>> set(findobj(gca, 'Type', 'Line', 'Linestyle', '--'), 'LineWidth', 2);
  댓글 수: 1
帅 赵
帅 赵 2021년 7월 11일
I can't make changes through set, But I can add parameters in setting with fplot

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

the cyclist
the cyclist 2014년 5월 8일
One way is to use fplot() to get the (x,y) values, then use plot() to do the plotting and then adjusting properties via the plot handles.
clear all;
close all
clc;
w1=0;
w2=16.73;
x1= @(t) 0.05*cos(w1.*t)-0.05*cos(w2.*t);
x2= @(t) 0.05*cos(w1.*t)+0.05*cos(w2.*t);
[xx1,yy1] = fplot(x1,[0,2],'k');
[xx2,yy2] = fplot(x2,[0,2],'--k');
hold on
h1 = plot(xx1,yy1,'k');
h2 = plot(xx2,yy2,'k');
hold off;
set([h1 h2],'LineWidth',2)
legend('x','y');
title('plot');
xlabel('t');
ylabel('d');

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by