在晶格的同一行中将0对齐 [英] align 0 in the same line in lattice

查看:82
本文介绍了在晶格的同一行中将0对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是ggplot2

library(ggplot2)

test <- data.frame(a=c('1','1','2','2'),b=c(2,-2,4,-3),d=c('m','n','m','n')) 

p <- ggplot(test,aes(a,b))

p + geom_bar(position=position_dodge(),stat='identity',
             fill='deeppink',colour='black',width=0.5)

由于某种原因,我需要使用lattice重新绘制图形,

for some reason, I need to re-draw the figure with lattice,

library(lattice)

a<-barchart(b~a,data=test)

所以我想使用latticeggplot2中的对齐方式.

so I want the same alignment as in ggplot2 by using lattice.

推荐答案

我认为您可以通过堆叠的条形图简单地得到想要的东西.

I think you can get what you want simply with a stacked barchart.

library(lattice)
barchart(b~a, data=test, col=c("#00FFFF"), group=d, stack=TRUE)

这篇关于在晶格的同一行中将0对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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