我不确定究竟该怎么称呼它,但我试图实现一种"破碎的直方图"或"轴间隙"效应:http://gnuplot-tricks.blogspot.com/2009/11/broken- histograms.html(例如在gnuplot中)与R.
看起来我应该使用包中的gap.plot()函数plotrix,但我只看到了使用散点图和线图的示例.我已经能够在我的情节周围的框中添加一个中断并在其中放置一个曲折,但我无法弄清楚如何重新缩放我的轴以放大休息下方的部分.
重点是能够在我的直方图中显示一个非常大的条形的最高值,同时放大我的大多数明显更短的箱子.(是的,我知道这可能会产生误导,但如果可能的话,我仍然希望这样做)
有什么建议?
更新5/10/2012 1040 EST:
如果我使用数据进行常规直方图并使用< - 将其保存到变量(hdata <- hist(...))中,我会得到以下变量的以下值:
hdata$breaks
[1] 0.00 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 0.31 0.32 0.33
[16] 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48
[31] 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.60 0.61 0.62 0.63
[46] 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78
[61] 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93
[76] 0.94 0.95 0.96 0.97 0.98 0.99 1.00
hdata$counts
[1] 675 1 0 1 2 2 0 1 0 2
[11] 1 1 1 2 5 2 1 0 2 0
[21] 2 1 2 2 1 2 2 2 6 1
[31] 0 2 2 2 2 3 5 4 0 1
[41] 5 8 6 4 10 3 7 7 4 3
[51] 7 6 16 11 15 15 16 25 20 22
[61] 31 42 48 62 57 45 69 70 98 104
[71] 79 155 214 277 389 333 626 937 1629 3471
[81] 175786
Run Code Online (Sandbox Code Playgroud)
我相信我想$breaks用作我的x轴和$countsy轴.
Eri*_*ail 12
您可以使用gap.barplotplotrix包中的.
# install.packages('plotrix', dependencies = TRUE)
require(plotrix)
example(gap.barplot)
Run Code Online (Sandbox Code Playgroud)
要么
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")
Run Code Online (Sandbox Code Playgroud)
会给你这个,

它是否可以facet_wrap与"free"(或"free_y")一起使用scales?这样您就可以并排比较数据,但具有不同的y标度
这是我的简单例子,
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")
Run Code Online (Sandbox Code Playgroud)
以上会给你这个,

| 归档时间: |
|
| 查看次数: |
18999 次 |
| 最近记录: |