相关疑难解决方法(0)

ggplot2直方图中每个面的不同中断

ggplot2挑战的latticist需要帮助:在直方图中请求变量per-facet中断的语法是什么?

library(ggplot2)
d = data.frame(x=c(rnorm(100,10,0.1),rnorm(100,20,0.1)),par=rep(letters[1:2],each=100))
# Note: breaks have different length by par
breaks = list(a=seq(9,11,by=0.1),b=seq(19,21,by=0.2))
ggplot(d, aes(x=x) ) + 
  geom_histogram() + ### Here the ~breaks should be added
  facet_wrap(~ par,  scales="free")
Run Code Online (Sandbox Code Playgroud)

正如jucor所指出的,这里还有一些解决方案.

根据特殊要求,并说明为什么我不是一个伟大的ggplot粉丝,lattice版本

library(lattice)
d = data.frame(x=c(rnorm(100,10,0.1),rnorm(100,20,0.1)),par=rep(letters[1:2],each=100))
# Note: breaks have different length by par
myBreaks = list(a=seq(8,12,by=0.1),b=seq(18,22,by=0.2))
histogram(~x|par,data=d,
          panel = function(x,breaks,...){
            # I don't know of a generic way to get the 
            # grouping variable with histogram, so 
            # this is not …
Run Code Online (Sandbox Code Playgroud)

r histogram ggplot2

16
推荐指数
2
解决办法
6391
查看次数

标签 统计

ggplot2 ×1

histogram ×1

r ×1