同时设置分面标记位置和 strip.text.y 时角度不生效问题

38 篇文章 7 订阅
同时设置分面标记位置和 strip.text.y 时角度不生效

最近在做peak reads 分布图时遇到一个问题,分面后同时设置分面标记的位置和分面文字的角度(strip.text.y= element_text( angle = 0))时文字角度无法生效。
解决办法:将 strip.text.y 改为 strip.text.y.left

ggplot2::scale_y_continuous(expand = c(0,0)) + # position = "right",
    # facet_wrap(.~sample, ncol = 1, scales = 'fixed', strip.position = 'left') +
    # facet_grid(sample ~ . , scales = "fixed",switch='y') +
    facet_grid(vars(sample), scales = "fixed", switch='y') +
    theme_classic() + theme(strip.placement = 'outside',
                            strip.background = element_blank(),
                            strip.text.y.left = element_text(size=10, angle = 0))
背后逻辑解答:

主题元素有一个层次结构:

strip.text inherits from text
strip.text.y inherits from strip.text
strip.text.y.left(右)继承自strip.text.y。
主题中的“继承”意味着,当子对象中缺少父对象的属性时,子对象的属性将由父对象的属性填充。

如果使用默认主题计算theme_get()$strip.text.y,您将看到angle是-90:未缺失。因此,每当你在父strip.text中设置一些东西时,strip.text.y的角度会覆盖父角度。Kara Woo曾在演讲中讨论了这种问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值