[R] Adding line plot to a barplot

Jim Lemon jim at bitwrit.com.au
Mon Feb 1 12:20:54 CET 2010


On 02/01/2010 05:40 PM, Nadine Kilsby wrote:
> Hi,
> I am trying to add a line plot of barplot, and while the following script
> works:
>
> barplot(DATA1,bty='c')
> par(new=T)
> plot(DATA2,type="l",axes=F,xlab="",ylab="",bty='c')
> axis(4)
>
> for some reason the y axis' do not align (the 0s are not in the same
> position). Is this because I am trying to overlay plot on barplot, and is
> there any way around this?

Hi Nadine,
If you use the same "ylim" argument for both plots, the axes should be 
the same.

Jim



More information about the R-help mailing list