如何最小化r中直方图上的间距
假设我有两种数据。一个在小范围内(从0到0.5),另一个在大范围内(从4到600)。第一个称为如何最小化r中直方图上的间距,r,ggplot2,histogram,R,Ggplot2,Histogram,假设我有两种数据。一个在小范围内(从0到0.5),另一个在大范围内(从4到600)。第一个称为v,第二个称为mx data<-structure(list(v = c(0.0741993337844943, 0.0469609897824665, 0.27686789382899, 0.0899877689865293, 0.0533351613571831, 0.0949535942113873, 0.132267448969788, 0.140736814439988, 0.170
v
,第二个称为mx
data<-structure(list(v = c(0.0741993337844943, 0.0469609897824665,
0.27686789382899, 0.0899877689865293, 0.0533351613571831, 0.0949535942113873,
0.132267448969788, 0.140736814439988, 0.170258755089611, 0.0012874981224646,
0.0167425549755457), mx = c(20.2159112302004, 15.2656614271742,
14.4361762323113, 8.87425807502441, 4.04997522826475, 34.9314254746675,
45.699439750261, 16.0238858355385, 79.4436180395085, 598.247400459265,
5.16677793308584)), class = "data.frame", row.names = c(NA, -11L
))
例如,v
图上没有介于0.0和0.1之间的值。我想给这个差距增加更多的值,比如0.01,0.02。。。对于另一个图,我想添加更多的值,比如0-10-20-30…200-210
简言之,我想最小化所有具有不同范围的图的所有间隙
data<-structure(list(v = c(0.0741993337844943, 0.0469609897824665, 0.27686789382899, 0.0899877689865293, 0.0533351613571831, 0.0949535942113873, 0.132267448969788, 0.140736814439988, 0.170258755089611, 0.0012874981224646, 0.0167425549755457),
mx = c(20.2159112302004, 15.2656614271742, 14.4361762323113, 8.87425807502441, 4.04997522826475, 34.9314254746675, 45.699439750261, 16.0238858355385, 79.4436180395085, 598.247400459265, 5.16677793308584)),
class = "data.frame", row.names = c(NA, -11L))
library(ggplot2)
ggplot(data, aes(x=data$v)) + geom_histogram(bins=10)
ggplot(data, aes(x=data$mx)) + geom_histogram(bins=10)
也许:
ggplot(data,aes(x=v))+geom_直方图(binwidth=0.01)
?不确定您想要实现什么:您的数据在图表中根本不包含任何空白值-也许geom_density()
在视觉上更接近您想要实现的目标。您还可以添加scale_x_log10()
为了减小间隙,请注意这可能会使轴更难理解。
data<-structure(list(v = c(0.0741993337844943, 0.0469609897824665, 0.27686789382899, 0.0899877689865293, 0.0533351613571831, 0.0949535942113873, 0.132267448969788, 0.140736814439988, 0.170258755089611, 0.0012874981224646, 0.0167425549755457),
mx = c(20.2159112302004, 15.2656614271742, 14.4361762323113, 8.87425807502441, 4.04997522826475, 34.9314254746675, 45.699439750261, 16.0238858355385, 79.4436180395085, 598.247400459265, 5.16677793308584)),
class = "data.frame", row.names = c(NA, -11L))
library(ggplot2)
ggplot(data, aes(x=data$v)) + geom_histogram(bins=10)
ggplot(data, aes(x=data$mx)) + geom_histogram(bins=10)
ggplot(data, aes(x=data$v)) + geom_histogram(binwidth=0.01)
ggplot(data, aes(x=data$mx)) + geom_histogram(binwidth=10)