1

When the data less than 5 columns or rows, there will be dummy grids. Is it possible to avoid this?

set.seed(123)
my.mat <- matrix(runif(20), nrow = 4)
dimnames(my.mat) <- list(LETTERS[1:4], letters[11:15])
s3d.dat <- data.frame(columns = c(col(my.mat)),
                  rows = c(row(my.mat)), value = c(my.mat))
scatterplot3d(s3d.dat, type = "h", lwd = 5, pch = " ",
          x.ticklabs = colnames(my.mat), y.ticklabs = rownames(my.mat))

The above codes were slightly modified based on the example from scattorplot3d vignettes, and will produce the following plot.

enter image description here

In the y-axis, there are dummy grids were added and the corresponding labels were repeated to cover extra grids. Any ideas to fix it?

Jaap
  • 81,064
  • 34
  • 182
  • 193
xukun
  • 11
  • 3
  • Thanks a lot, CathG! – xukun Sep 02 '15 at 11:53
  • the problem comes I think from the fact that you're specifying less values for labels than there are for "grid values" : try to draw the picture without specifying y.ticklabs, you'll see that there are ticks every 0.5 so you need to specify that you want only 4 ticks for this axis – Cath Sep 02 '15 at 12:00
  • thanks again, CathG. I have tried this but still extra grids still there and I have no idea to increase the step from 0.5 to 1 to avoid this. After read the manual carefully, I found this about the xlim, ylim and zlim: "the x, y and z limits (min, max) of the plot. Note that setting enlarged limits may not work as exactly as expected (a known but unfixed bug)." – xukun Sep 02 '15 at 12:05
  • Roman's answer is the way to go :-) – Cath Sep 02 '15 at 12:11

1 Answers1

2

I will steal @CathG's thunder and show you how to specify number of x and y ticks.

scatterplot3d(x, type = "h", lwd = 5, pch = " ", lab = c(length(colnames(my.mat)), length(rownames(my.mat))),
              x.ticklabs = colnames(my.mat), y.ticklabs = rownames(my.mat))

Notice that I specified a lab argument that specifies the number of ticks on x and y. enter image description here

Cath
  • 23,906
  • 5
  • 52
  • 86
Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
  • @xukun if the answer solved your problem, consider accepting the answer as the correct one (by clicking the grey check mark under the score). – Roman Luštrik Sep 02 '15 at 19:04
  • thanks, Roman! I am new to here and just realise that what should I do after accepting your answer. – xukun Sep 03 '15 at 14:52