首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ggmosaic:当因子水平计数为0时,如何去除细线

ggmosaic:当因子水平计数为0时,如何去除细线
EN

Stack Overflow用户
提问于 2017-03-06 02:14:06
回答 1查看 200关注 0票数 0

我一直在尝试使用the thin line marking a hspine with the count of 0 (second column)来绘制一个马赛克/马里梅科图,但我希望删除它。

这可以在ggmosaic中完成吗?我在vignette / help文件中找不到方法。下面是一个可重现的例子。

代码语言:javascript
复制
library(ggmosaic)    

happy2 <- happy
happy2$marital <- 
  ifelse(happy2$marital == "never married" & happy2$happy == "not too happy",
       NA, happy2$marital)

ggplot(happy2) + 
  geom_mosaic(aes(x = product(happy, marital), fill = happy))
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-09 15:14:21

我不知道它是否可以在ggmosaic中进行调整,但事实证明,使用ggplot可以非常轻松地完成此图

代码语言:javascript
复制
happy2 <- happy
happy2$marital <- 
  ifelse(happy2$marital == "never married" & happy2$happy == "not too happy",
       NA, happy2$marital)

ggplot(happy2) + 
  geom_histogram(aes(x = marital, fill = happy), colour = "black", 
               width = 1, stat = "count", position = "fill") +
  scale_y_continuous(expand = c(0,0)) +
  scale_x_discrete(expand = c(0,0))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42612085

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档