1

I am trying to fit in 13 plots in one image but the plots in the image seem to be stretched and is not clear.

My Problem

This is currently my coding progress:

par(mfrow=c(4,4))
plot(johordata,series = "male", main = "Johor")
plot(kedahdata,series = "male", main = "Kedah")
plot(kelantandata,series = "male", main = "Kelantan")
plot(melakadata,series = "male",main = "Melaka" )
plot(nsembilandata,series = "male",main = "Negeri Sembilan")
plot(pahangdata,series = "male",main = "Pahang")
plot(perakdata,series = "male",main = "Perak")
plot(perlisdata,series = "male",main = "Perlis")
plot(ppinangdata,series = "male",main = "Pulau Pinang")
plot(sabahdata,series = "male",main = "Sabah")
plot(sarawakdata,series = "male",main = "Sarawak")
plot(selangordata,series = "male",main = "Selangor")
plot(terengganudata,series = "male",main = "Terengganu")

Thus, I'm trying to figure out the right way for the 13 plots to look like this:

Like this

jay.sf
  • 60,139
  • 8
  • 53
  • 110
  • 1
    How are you outputting the plots? pdf, jpeg, png? Read the manuals they have height and width arguments. You need to fix the aspect ratio so that every plot appears more square. – zx8754 Jan 14 '21 at 06:13

1 Answers1

1

As @zx8754 said in the comments, you should use the png or pdf device, to make the result independent of the current scaling of your plots window. See this Q&A. In addition you may want to screw a little more on the par options, e.g. using mar=. Just read ?par help file. Example:

png("X:/plot1.png", width=480, height=480)
op <- par(mfrow=c(4, 4), mar=c(4, 4, 2.5, 1.5))  ## set pars and store defaults
replicate(16, plot(mpg ~ hp, mtcars, col=4))
par(op)  ## reset par defaults
dev.off()

enter image description here

jay.sf
  • 60,139
  • 8
  • 53
  • 110