No data plotted in graph

9 次查看(过去 30 天)
Ellen Walker
Ellen Walker 2018-9-18
I am trying to plot two curves on the same graph for multiple animals and multiple sessions for each animal that will generate a new plot for each neuron.
Also, I would like one curve to be green and the other red, as stated below, but, in the legend, both are appearing green.
I have tried the following code and get a graph with the proper axes but no data plotted:
sm=smooth(M,500,'lowess');
sm2=smooth(N,500,'lowess');
nunit=nunit+1;
plot(sm,nunit,'g',sm2,nunit,'r');
legend('MV in water','2H in saccharin');
title({animal;session})
Not sure what I am doing wrong; thank you for your help!!
  2 个评论
dpb
dpb 2018-9-19
...
nunit=nunit+1;
plot(sm,nunit,'g',sm2,nunit,'r');
...
nunit is just a single point and you don't have a marker and since there's not more than one point between which plot() can draw a line, there's nothing going to show up.
Also, if you're going to plot in a loop, then you needs must use
hold on
in order for each subsequent point to not erase those who've gone before.
In general you should generate all the data to plot first, then call plot() with and X,Y array to do the plotting.
Also while you've not shown the loop, as shown you would be rewriting the legend and title every pass; even if you continue to plot point-by-point, move those out and wait until the loop is complete.
One thing you can do in your existing code to see what's happening as it currently is written is use
plot(sm,nunit,'gx',sm2,nunit,'ro');
pause 0.1
Ellen Walker
Ellen Walker 2018-9-19
Thank you for your help!!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by