[英]How to plot a filled contour, with z axis being a factor
I have a dataset 我有一个数据集
test<-data.frame(expand.grid(x=seq(0.01,1,0.01), y=seq(0.01,1,0.01)))
test$z<-c(rep(1,2500),rep(2,2500),rep(3,2500),rep(4,2500))
(x,y) define cartesian coordinates. (x,y)定义笛卡尔坐标。 I would like to plot a filled contour plot, with
xlim=ylim=c(0,1)
, and the color being z (a factor with 4 levels). 我想绘制一个填充的等高线图,其中
xlim=ylim=c(0,1)
,颜色为z(具有4个等级的因子)。
i could do : 我可以做 :
plot(test$x, test$y, col=test$z, pch=16)
but it does not look good. plot(test$x, test$y, col=test$z, pch=16)
但看起来不太好。
The example looks terrible but in my data makes sense. 这个例子看起来很糟糕,但在我的数据中是有道理的。 I am familiar with
akima::interp
and filled.contour()
but i do not wish any interpolation and z is not continuous but a factor. 我熟悉
akima::interp
和filled.contour()
但我不希望任何插值和z不连续但是一个因素。
Could you please recommend me a proper and pleasant visualization for my data? 能否请您为我的数据推荐一个适当且令人愉快的可视化? I would prefer base graphics.
我更喜欢基本图形。
You can use image
for example : 您可以使用
image
,例如:
image(outer(seq(0.01,1,0.01),seq(0.01,1,0.01),
FUN=function(x,y)test$z))
I think you can use raster
package to deal better with such plots. 我认为你可以使用
raster
包来更好地处理这些情节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.