[R] adding points in plot loop
Duncan Murdoch
murdoch.duncan at gmail.com
Wed Mar 23 10:55:43 CET 2016
On 23/03/2016 5:36 AM, catalin roibu wrote:
> Dear R users,
>
> I have a dataframe with 6 columns and I want to create a plot (with for
> loop). My question is how to add points in the for loop? I tried this code,
> but without success.
>
> vv<-rbind(colnames(ext))
> for(i in 1:ncol(vv)){
> with(ext, plot(rownames(ext), ext[,i], type="p",las=1,
> bty="n",cex.main=2, cex.axis=1.5))
> }
>
> Please help me to solve that!
You can call the points() function to add points to an existing plot.
The main difficulty is that the initial call to plot() establishes the
axes and coordinate system; if later points fall outside the plot area,
they won't be shown. So you may need to work out xlim and ylim in advance.
Duncan Murdoch
More information about the R-help
mailing list