1

I plotted the values using this code:

png(filename="q.png", width=3000, height=1600, units="px")

but the values on x and y axes appeared to be too small. I want to magnify them. How do I do that?

Dason
  • 60,663
  • 9
  • 131
  • 148
rockswap
  • 623
  • 1
  • 7
  • 17
  • 1
    The png function does not do any plotting, it just opens a PNG file. What are the plot calls? Put this in your question. – mdsumner May 20 '12 at 22:40
  • Please check this questions before going on asking things that are explained in about every basic manual on R : [How to Search for R materials](http://stackoverflow.com/questions/102056/how-to-search-for-r-materials) and [List of R tutorials](http://stackoverflow.com/questions/2266200/where-can-i-find-useful-r-tutorials-with-various-implementations) – Joris Meys May 21 '12 at 09:59

3 Answers3

8

I suspect that you need to change it when you plot the graph, for example:

 par(mar=c(4,5,1,1))
 plot(rnorm(30), xlab= "Big font", ylab = "Big font", cex.lab = 2, cex.axis = 1.5)

Example:

EDITED 1: To change the title size:

par(mar=c(5,5,4,1))
plot(rnorm(30), xlab= "Big font", ylab = "Big font", 
    cex.lab = 2, cex.axis = 1.5, cex.main=3, main="Big Font")

enter image description here

EDITED 2: Shaded plot area. Not sure if this is the best way to do it. There may be simpler and more elegant ways to shade the plot area.

a = rnorm(30)
par(mar=c(5,5,4,1))
plot(a, xlab= "Big font", ylab = "Big font", type="n",
     cex.lab = 2, cex.axis = 1.5, cex.main=3, main="Big Font")
x <- par("usr")
rect(x[1], x[3], x[2], x[4], col = "grey")
points(a, pch=19)

enter image description here

Alex
  • 4,030
  • 8
  • 40
  • 62
  • I did that. But I am unable to magnify the Title(main) of the plot. this only magnifies the x and y lab. – rockswap May 20 '12 at 23:05
2

You can set the text magnification with 'par':

opar <- par(cex.axis = 1.5)
# plotting commands
par(opar)

In addition, to set the main text, labels and sub-title text sizes with cex.main, cex.lab and cex.sub, respectively:

opar <- par(cex.axis = 1.5, cex.main = 1.5, cex.lab = 1.5, cex.sub = 1.5)
...

Setting 'cex' alone will also magnify the plotted symbols, which may be appropriate, and may not.

These are described in ?par

Matthew Lundberg
  • 42,009
  • 6
  • 90
  • 112
  • I tried this, but this does not magnify the title. And also the ylab is going out of the plot...can you please figure this out? – rockswap May 20 '12 at 22:59
  • Edited answer to add the the first. As for the ylab being too long, if it's too highly magnified, you can reduce the text size or the length of the text. – Matthew Lundberg May 20 '12 at 23:05
  • That worked... Can I make my plot a bit darker...(in the plotting area) – rockswap May 20 '12 at 23:13
  • @rockswap I edited my original reply to include a code to shade the plot area. Check it out. – Alex May 21 '12 at 01:17
1

Include cex.main, cex.sub, cex.lab in your plot command.

http://www.rseek.org/

search for par in this link. this is a search directory for all commands of r software

Swapnil 'Tux' Takle
  • 1,187
  • 2
  • 9
  • 9