![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/299138/image.png)
How to produce a scatter plot with smooth line for this plot?
15 ビュー (過去 30 日間)
古いコメントを表示
Ashvinder Singh Gill Surmaish Singh Gill
2020 年 5 月 24 日
コメント済み: Ashvinder Singh Gill Surmaish Singh Gill
2020 年 5 月 24 日
Attached is the capture.png which shows the desired smooth plot that I would like to have. FYP Sample Data.PNG is what I have been getting through the codes below but I need smooth plot just like the one produced in Capture.png.
Can anyone guide how can I produce scatter plot with smooth lines please similar to the Capture.PNG?
Appreciate if anyone can help me. God Bless You!
data = xlsread("sampleexceldata.xlsx") ;
K = data(1,[1 3 5]) ; % factors
data(1,:) = [];
s1 = data(:,1) ; f1 = data(:,2) ;
s2 = data(:,3) ; f2 = data(:,4) ;
s3 = data(:,5) ; f3 = data(:,6) ;
figure
yyaxis right
plot(s3,f3,'g-o',s2,f2,'b-+')
axis ([0 5 0 90])
ylabel('Force (N)');
yyaxis left
plot(s1,f1,'r-*')
axis ([0 5 0 13])
grid on
title('Force vs Displacement');
xlabel('Displacement (mm)');
ylabel('Force (N)');
0 件のコメント
採用された回答
Thiago Henrique Gomes Lobato
2020 年 5 月 24 日
Those smooth lines are interpolations between the given points. For you to have a similar result, what you need to do is find an interpolation that is suitable for your expectations about the data and then simply interpolate before plotting. An simple example can be seen below, where the difference between a linear (default) and cubic interpolation can be seen check interp1:
x = 1:10;
y = (-1).^(x);
xq = 1:0.01:10;
yq = interp1(x,y,xq,'PCHIP') ;
figure,plot(x,y,'g-o','linewidth',2)
hold on,plot(xq,yq,'linewidth',2),plot(xq(1:100:end),yq(1:100:end),'r+','linewidth',2)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/299138/image.png)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!