我已经使用openair
和hexbin
软件包在散点图功能命令的帮助下创建了两个散点图:
scatterPlot(mydata, x ="Observed" , y = "Model1",xlab=10, ylab=10,method = "hexbin",mod.line=T,auto.text=F, col = "jet", xbin = 30)
scatterPlot(mydata, x ="Observed" , y = "Model2",xlab=10, ylab=10,method = "hexbin",mod.line=T,auto.text=F, col = "jet", xbin = 30)
我已经有了散点图,但是如果我想将它们放到一个图上并用一种颜色计数,就可以得到类似的结果:我应该如何进行?
please refer to this link to view the image : https://ibb.co/rF148kp
答案 0 :(得分:0)
您可以重新组织数据框,使其具有三列-“已观察”,“已建模”和“模型类型”。示例-
structure(list(observed = c(2L, 2L, 4L, 4L, 6L, 6L, 8L, 8L, 10L,
10L, 12L, 12L, 14L, 14L, 16L, 16L, 18L, 18L, 20L, 20L), modelled = c(1L,
5L, 7L, 2L, 5L, 9L, 13L, 15L, 16L, 14L, 18L, 17L, 10L, 21L, 26L,
24L, 22L, 28L, 27L, 30L), model_type = structure(c(1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L), .Label = c("Model 1", "Model 2"), class = "factor")), class = "data.frame",
row.names = c(NA,
-20L))
这样,您就可以使用以下代码-
scatterPlot(mydata, x = "observed", y = "modelled", type = c("model_type"),
method = "hexbin",mod.line=T,auto.text=F, col = "jet", xbin = 5,
linear = TRUE, layout = c(2, 1))
创建一个包含两个散点图的图。注意,上面的代码将xbin设置为5纯粹是因为我出于测试目的使用了一个小的数据集。另外,请原谅y轴和代码的拼写错误(“ modelled”应为“ modeled”)!