如何为值的网格而不是直线生成序列?

时间:2019-03-15 06:14:08

标签: r ggplot2 plot grid

序列必须是

- `a0grid`  including increments of 100 between starting at 500 and up to 2500 [500,600,700,...,2200,2300,2400,2500] 
- `a1grid` including increments of 10  between -100 and 100 [-100,-90,-80,...,80,90,100] 

初始化:

a0 <- seq(500,2500,by=100)
a1 <- seq(-100,100,by=10)

 [1]  500  600  700  800  900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500
 [1] -100  -90  -80  -70  -60  -50  -40  -30  -20  -10    0   10   20   30   40   50   60   70   80   90  100

我现在正在得到什么:

enter image description here

我要查找的内容(不完全是,而是指向如图所示的所有地方):

enter image description here

1 个答案:

答案 0 :(得分:3)

如果您想在任何地方都可以使用expand.grid

library(ggplot2)

ggplot(expand.grid(a0, a1)) + 
    geom_point(aes(x=Var1,y=Var2))

enter image description here


这个情节也可以不用任何包装来完成

plot(expand.grid(a0, a1), pch = 16)

enter image description here