2

我已经成功地为我的数据集中所有年份和月份的可变风速制作了直方图。但我希望 x 轴以 1 英里/小时的间隔标记。每个箱也是 1 英里/小时的间隔。目前默认情况下,x 轴以 20 英里/小时的间隔标记。

这是我的 R 代码。

histogram(~ as.numeric(spd) | factor(month) + factor(year), data = spd_sub, 
  xlab = "spd in miles/hour", 
  nint= max(as.numeric(spd))-min(as.numeric(spd)), layout = c(1, 1))

知道怎么做吗?

4

1 回答 1

5

也许这没什么好考虑的。注意使用scales.

library(lattice)
Depth <- equal.count(quakes$depth, number=8, overlap=.1)
xyplot(lat ~ long | Depth, data = quakes)

这为您提供了以下图表。 在此处输入图像描述

如果你设置 scales 参数:

xyplot(lat ~ long | Depth, data = quakes,
        scales = list(y = list(at = seq(from = 0, to = -50, by = -10))))

在此处输入图像描述

一个免费的直方图(更改刻度线并旋转它们):

histogram( ~ height | voice.part, data = singer,
    xlab = "Height (inches)", type = "density",
    panel = function(x, ...) {
        panel.histogram(x, ...)
        panel.mathdensity(dmath = dnorm, col = "black",
            args = list(mean=mean(x),sd=sd(x)))
    },
    scales = list(x = list(at = seq(60, 80, by = 2), rot = 45)))

在此处输入图像描述

于 2011-09-10T17:35:24.587 回答