trend line not drawing in sub-plot
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I have this really strange issue going and it is really confusing me. I am trying to plot a trend line through a set of data and I can do it just fine in a regular plot, but as soon as I add it to a sub-plot, I can get either the data or the trend line and not both.
I did try to do it with the toolbox but in a subplot figure, I can only get 1 trend line to show up on any of my 5 subplots at a given time. so both methods are 'either or' and not both :(
any help would be greatly appreciated. thanx.
here is my code i am testing with.
a = [1 2 3 4 5]';
b = [3 7 9 3 7]';
figure
hold all
plot (a,b);
% plot trend line
f = fittype('a*x+b'); %define fittype
fitobj = fit(a,b,f); %fit line to data
plot (fitobj,'k') %plot trend line
figure
subplot(2,1,1)
plot (a,b);
% plot trend line
f = fittype('a*x+b'); %define fittype
fitobj = fit(a,b,f); %fit line to data
plot (fitobj,'k') %plot trend line
0 comentarios
Respuesta aceptada
Sean de Wolski
el 24 de Abr. de 2012
You need to hold on to your subplot!
figure
subplot(2,1,1)
hold on
plot (a,b);
% plot trend line
f = fittype('a*x+b'); %define fittype
fitobj = fit(a,b,f); %fit line to data
plot (fitobj,'k') %plot trend line
Más respuestas (0)
Ver también
Categorías
Más información sobre Fit Postprocessing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!