Search code examples
rplotpar

How can add space in this plot ? I am a beginner in R


Here is the code for plotting 10 different graphs

lab=unique(train_train$PdDistrict)
lab=as.character(lab)
par(mfrow=c(5,2))

for(i in 1:length(lab))
{
  a=plot(table(train_train[train_train$PdDistrict==lab[i],1]),las=3,main=lab[i])
}

The resultant graph is shown in this image link

IMAGE

How can i space those graphs so that its readable ?


Solution

  • My new code that I modified

    lab=unique(train_train$PdDistrict)
    lab=as.character(lab)
    par(mfrow=c(1,2),mar=c(9,4,1,0))
    
    for(i in 1:length(lab))
    {
    
      a=plot(table(train_train[train_train$PdDistrict==lab[i],1]),las=2,main=lab[i])
    }
    

    enter image description here

    Now it looks much better.