如何更改使用R中的Lattice软件包制作的直方图中x轴上的比例? [英] How to change the scales on the x axis in the Histogram made using Lattice package in R?

查看:59
本文介绍了如何更改使用R中的Lattice软件包制作的直方图中x轴上的比例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have been successful in making the Histogram for the variable wind speed for all years and months in my data set. But I want the the x-axis labeled at 1 mile/hr intervals.Each bin is also of 1 mile/hr interval. Currently by default the x axis is labeled at 20 miles/hour intervals.

这是我的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))

任何想法如何做到这一点?

Any idea how to do this?

推荐答案

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

Maybe this could be little something to think about. Notice the use of scales.

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

这将为您提供下图.

如果您设置了scales参数:

And if you set the scales argument:

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

免费提供一个直方图(更改了刻度线并旋转了刻度线):

One gratis with a histogram (changed the tick marks and rotated them):

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)))

这篇关于如何更改使用R中的Lattice软件包制作的直方图中x轴上的比例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆