0

Please consider those data example:

e3 <- data.frame(400)
e3 <- rep( c("high", "medium", "low", "personal", "SPAM"), c(60, 120, 20, 50, 150))

I create a pie chart, and I placed the legend outside the margins of the chart, like straightforwardly discussed here.

par(mar=c(5.1, 4.1, 4.1, 8.1), xpd=TRUE)
pie(table(e3), labels = paste(round(prop.table(table(e3))*100), "%", 
    sep = ""), col = heat.colors(5), main = "Mail received - n: 400"),     
    legend("topright", legend = c("High", "Medium", "Low", "Personal", 
    "SPAM"), fill = heat.colors(5), inset=c(-1,0), title = "Categories", cex = 0.55)

enter image description here

The problem is that the margins around the plot are not visible. I added lwd = 2, col = "black" to par(), but nothing appears while I would a "black rectangle" around the chart. Most likely, my intervention is not correctly directed. Any suggestion or constructive criticism is really appreciated.

Community
  • 1
  • 1
Worice
  • 3,847
  • 3
  • 28
  • 49
  • 2
    What do you mean by "margins around the plot are not visible"? From what you tried, I assume you want a black border, which you can plot using `box()`. – lukeA Feb 07 '16 at 13:22
  • @lukeA yes you are right. Sorry for the poor explanation. – Worice Feb 07 '16 at 13:23
  • @lukeA just a question. I suppose that modifying the `box()` size is possible. I tried with `mar=c(5.1, 4.1, 4.1, 8.1)`, no make it smaller, with no effect. Do you have any suggestion? – Worice Feb 07 '16 at 13:52
  • 2
    try also setting the outer margin... `par(oma=c(2,2,2,2), mar=c(5.1, 4.1, 4.1, 8.1), xpd=TRUE) ; yourplots ; box("inner", lty="dotted", col="red", lwd=3)` – user20650 Feb 07 '16 at 14:05
  • 1
    If you want to expand the box, you could do `usr <- par("usr")*1.2; rect(usr[1], usr[3], usr[2], usr[4], lwd=2, col=NA)`. I don't know what you end result looks like. – lukeA Feb 07 '16 at 14:12

0 Answers0