4

I designated the width, height, and resolution of the plot, then removed the margins as in the below code, and drew a plot.

But I still have margins. I got the same plot with and without the par command. The uploaded image was reduced from 7000*5000 to 1400*1000 to reduce under 2MB.

enter image description here

library(scatterplot3d)

parwd = 7000
parht = 5000
parres = 1000

par(oma = c(0,0,0,0), mar = c(0,0,0,0))

jpeg(filename="CC_1_fo.jpg", width = parwd, height = parht, res = parres)
scatterplot3d(1:10, 1:10, 1:10,
              cex.symbol = 0.2,
              xlab = expression(T[1]),
              ylab = expression(T[2]),
              zlab = expression(tau))
dev.off()

How can I really remove the margins?

Axeman
  • 32,068
  • 8
  • 81
  • 94
user67275
  • 1
  • 9
  • 38
  • 64
  • 3
    Could you add a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610)? – Jaap Jul 26 '16 at 08:16
  • 1
    @ProcrastinatusMaximus I don't understand why you ask reproducible example because the data don't matter in this question. Anyway I edited the question – user67275 Jul 26 '16 at 08:20
  • 7
    I asked for data, because that makes it a lot easier for other people to reproduce your problem and thus makes it easier to help you. – Jaap Jul 26 '16 at 08:27

1 Answers1

6

I guess 3D plotting is a bit funky and some of the par arguments don't work as expected. Specifically, if you want to set margins with mar you have to use the actual mar argument in scatterplot3d.

This is stated in the notes of the help (?scatterplot3d):

Some graphical parameters should only be set as arguments in scatterplot3d but not in a previous par() call. One of these is mar (...)

Using:

scatterplot3d(1:10, 1:10, 1:10,
              cex.symbol = 0.2,
              xlab = expression(T[1]),
              ylab = expression(T[2]),
              zlab = expression(tau),
              mar = c(0,0,0,0))

will result in a plot without margins:

enter image description here

Setting the margins to zero will cut off your tick-labels though.

Jaap
  • 81,064
  • 34
  • 182
  • 193
Axeman
  • 32,068
  • 8
  • 81
  • 94
  • `mar = c(2.7, 2.7, 0, 2)` is a good default that reduces the margins without cutting away labels (with c(bottom, left, top, right)) – nevrome Aug 09 '20 at 18:07