带有莱迪思&的垂直盒百分图panel.bpplot [英] Vertical box-percentile plot with Lattice & panel.bpplot

查看:156
本文介绍了带有莱迪思&的垂直盒百分图panel.bpplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R中的框百分数图,使用Hmisc(panel.bpplot)中的框百分数面板功能和lattice中的bwplot.

I am drawing box-percentile plots in R, using the box-percentile panel function from Hmisc (panel.bpplot) with bwplot from lattice.

我有一个数字矢量(Length),想显示它在因子变量(Month)的各个层次上的分布.

I have a numeric vector (Length), and would like to show its distribution across the levels of a factor variable (Month).

这是一个伪造数据的例子:

Here's an example with fake data:

例如,

set.seed(13)
Length<-sample(1:10, 1000, replace=TRUE)
Month<-sample(c("Apr","May","Jul","Aug","Sep","Nov"), 1000, replace=TRUE)

df<-cbind(Month, Length)
df<-as.data.frame(df)   
df$Month<-factor(df$Month, levels=c("Apr","May","Jul","Aug","Sep","Nov"))
df$Length<-as.numeric(df$Length)

#plot horizontal box-percentile plot; 
bwplot(Month~Length, data=df, panel=panel.bpplot)

这很好.但是我希望这些图是 vertical ,在x轴上是Month在y轴上是Length. panel.bpplot的文档说,水平图使类别级别更清晰可见,但就我的目的而言,我特别需要垂直图.有没有办法修改panel.bpplot来做到这一点?

This works fine. But I want the plots to be vertical, with Month on the x-axis and Length on the y-axis. The documentation for panel.bpplot says that horizontal plots make category levels more visible, but, for my purposes, I specifically need a vertical plot. Is there a way to modify panel.bpplot to do this?

推荐答案

我从

I took some tips from this previous question and then merged it with your code. It seems the "trick" is setting up a rotated grid:

require(grid)
grid.newpage()
pushViewport(viewport(angle = 90, name = "VP"))
print(
    bwplot(Month~Length, data=df, panel=panel.bpplot, draw.in = "VP"
    ),
    newpage=FALSE
)

其结果是:

这篇关于带有莱迪思&amp;的垂直盒百分图panel.bpplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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