简体   繁体   English

R散点图矩阵小比例尺

[英]R Scatterplot matrix small scales

I have a dataframe of 4 variables and let's say 100 entries. 我有一个4个变量的数据框,比方说100个条目。 This variables are dummies that varies in small scales (1-5). 该变量是在较小范围内变化的虚拟变量(1-5)。 Is there a way to acknowledge the density of the points plotted in the scatterplot? 有没有办法确认散点图中绘制的点的密度? By having my points varying only between 1,2,3,4,& 5 many of them are located at the same place therefore I cannot see a pattern emerging as they are perfectly overlapping. 通过使我的点仅在1,2,3,4,&5之间变化,它们中的许多位于同一位置,因此我看不到出现的模式,因为它们完全重叠。

A first possibility would be to use jitter ; 第一种可能是使用jitter ; and a second to use transparent Colors: 第二种使用透明颜色:

set.seed(1)
df <- data.frame(var1 = sample(1:5, size = 100, replace = TRUE),
                 var2 = sample(1:5, size = 100, replace = TRUE))

plot(jitter(var1) ~ jitter(var2), data = df)

plot(var1 ~ var2, data = df, col = "#20000050")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM