I'm plotting distance (X) versus different in duration of a sound signal across two different conditions (Y).
When I plot just the raw differences, I can plot several comparisons, plus a dotted black line at Y=0 for a reference (neg vs. pos differences).
When I try to plot those differences as percents (basically, (Y2-Y1)/Y1), I get a solid color line at Y=0, in addition to the black dotted one. If I plot one line at a time I can see that this straight colored line comes up even when I'm just plotting one of them.
Please see attached figure for comparison/illustration.
Parts of the respective codes (they are largely identical):
Raw differences
%Taking differences from Baseline
OneD10DegDiff=OneD10Deg-OneDBaseline;OneD20DegDiff=OneD20Deg-OneDBaseline;OneD30DegDiff=OneD30Deg-OneDBaseline;OneD40DegDiff=OneD40Deg-OneDBaseline;TwoD10DegDiff=TwoD10Deg-TwoDBaseline;TwoD20DegDiff=TwoD20Deg-TwoDBaseline;TwoD30DegDiff=TwoD30Deg-TwoDBaseline;TwoD40DegDiff=TwoD40Deg-TwoDBaseline;%Plot
hold onplot(Data1D(:,1),OneD10DegDiff,'-r','LineWidth',2);plot(Data1D(:,1),OneD20DegDiff,'-m','LineWidth',2);plot(Data1D(:,1),OneD30DegDiff,'-g','LineWidth',2);plot(Data1D(:,1),OneD40DegDiff,'-b','LineWidth',2);plot(Data2D(:,1),TwoD10DegDiff,'-.r','LineWidth',2);plot(Data2D(:,1),TwoD20DegDiff,'-.m','LineWidth',2);plot(Data2D(:,1),TwoD30DegDiff,'-.g','LineWidth',2);plot(Data2D(:,1),TwoD40DegDiff,'-.b','LineWidth',2);plot([0,180],[0,0],':k','LineWidth',2);axis([0 180 -0.25 0.1])title([Name ' Percent Difference from Baseline'])xlabel('Target Distance')ylabel('Percent Duration Difference from Baseline (in ms)')
For percent differences:
%Taking differences from BaselineOneD10DegDiff=(OneD10Deg-OneDBaseline)/OneDBaseline;OneD20DegDiff=(OneD20Deg-OneDBaseline)/OneDBaseline;OneD30DegDiff=(OneD30Deg-OneDBaseline)/OneDBaseline;OneD40DegDiff=(OneD40Deg-OneDBaseline)/OneDBaseline;TwoD10DegDiff=(TwoD10Deg-TwoDBaseline)/TwoDBaseline;TwoD20DegDiff=(TwoD20Deg-TwoDBaseline)/TwoDBaseline;TwoD30DegDiff=(TwoD30Deg-TwoDBaseline)/TwoDBaseline;TwoD40DegDiff=(TwoD40Deg-TwoDBaseline)/TwoDBaseline;%Plothold onplot(Data1D(:,1),OneD10DegDiff,'-r','LineWidth',2);plot(Data1D(:,1),OneD20DegDiff,'-m','LineWidth',2);plot(Data1D(:,1),OneD30DegDiff,'-g','LineWidth',2);plot(Data1D(:,1),OneD40DegDiff,'-b','LineWidth',2);plot(Data2D(:,1),TwoD10DegDiff,'-.r','LineWidth',2);plot(Data2D(:,1),TwoD20DegDiff,'-.m','LineWidth',2);plot(Data2D(:,1),TwoD30DegDiff,'-.g','LineWidth',2);plot(Data2D(:,1),TwoD40DegDiff,'-.b','LineWidth',2);plot([0,180],[0,0],':k','LineWidth',2);axis([0 180 -0.25 0.1])title([Name ' Percent Difference from Baseline'])xlabel('Target Distance')ylabel('Percent Duration Difference from Baseline (in ms)')
Best Answer