"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i8iocc$qa0$1@fred.mathworks.com>...
> "Jonathan" <jkakiwi@yahoo.co.uk> wrote in message <i8injg$5ip$1@fred.mathworks.com>...
> > Ok, I'm trying to plot a very simple relationship (x,y). I would like to then show the mean position as a straight line. Here's my code...
> >
> > plot(B_1,time,'k','Marker','o','MarkerEdgeColor','k','MarkerFaceColor','k','MarkerSize',9)
> > hold on
> > xmin=min(B_1);
> > xmax=max(B_1);
> > ymin=731947;
> > ymax=734504;
> > axis([xmin,xmax,ymin,ymax]);
> > line([0 0],[ymin ymax],'LineStyle',':','Color','b','LineWidth',2) %plot line at zero
> > a=mean(B_1) %find the mean value
> > line([a a],[ymin ymax],'LineStyle','','LineWidth',3,'Color',[.8 .8 .8]);
> > set(gca,'YTick',[731947 732313 732678 733043 733408 733774 734140])
> > set(gca,'YTickLabel',{'2004' '2005' '2006' '2007' '2008' '2009' '2010'})
> >
> > The problem lies with second 'line' statement, near the bottom of the script. I don't understand why matlab is refusing to plot the line at location mean? What it is doing is replacing the line at zero. Am I missing something here?
> >
> > Thanks
> > Jon
>
> I think it's drawing your line, it's just outside of your axis.
>
> Work your way up. Only plot the main part. Then add each additional line, without using the axis command or the tick marks...
If I specify the x values determined by the mean value directly it plots the line correctly. However, if I use 'a' to specify mean it does not seem to like it.
I did notice that the avalue is in scientific notation. Would this have an effect?
