Put a break in the Y-Axis of a histogram

℡╲_俬逩灬. 提交于 2019-11-27 01:37:53

You could use the gap.barplot from the plotrix package.

# install.packages('plotrix', dependencies = TRUE)
require(plotrix)

   example(gap.barplot)

or

twogrp<-c(rnorm(10)+4,rnorm(10)+20)
gap.barplot(twogrp,gap=c(8,16),xlab="Index",ytics=c(3,6,17,20),
ylab="Group values",main="Barplot with gap")

Will give you this,

update 2012-05-09 19:15:42 PDT

Would it be an option to use facet_wrap with "free" (or "free_y") scales? That way you would be able to compare the data side by side, but have different y scales

Here is my quick example,

library('ggplot2')

source("http://www.ling.upenn.edu/~joseff/rstudy/data/coins.R")
coins$foo <- ifelse(coins$Mass.g >= 10,  c("Low"), c("hight")) 
m <- ggplot(coins, aes(x = Mass.g)) 
m + geom_histogram(binwidth = 2) + facet_wrap(~ foo, scales = "free")

The above would give you this,

This seems to work:

gap.barplot(hdata$counts,gap=c(4000,175000),xlab="Counts",ytics=c(0,3500,175000),
    ylab="Frequency",main="Barplot with gap",xtics=hdata$counts)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!