How to produce a scatter plot with smooth line for this plot?
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ashvinder Singh Gill Surmaish Singh Gill
el 24 de Mayo de 2020
Comentada: Ashvinder Singh Gill Surmaish Singh Gill
el 24 de Mayo de 2020
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 comentarios
Respuesta aceptada
Thiago Henrique Gomes Lobato
el 24 de Mayo de 2020
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)
1 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Scatter Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!