更改辅助线轴颜色 [英] Change secondary line axis color

查看:98
本文介绍了更改辅助线轴颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ggplot2中,如何仅在sec.axis上修改axis.line.y(如果可能)?

In ggplot2, how can I modify axis.line.y only on the sec.axis (if possible)?

    p <- ggplot(mtcars, aes(cyl, mpg)) +
      geom_point()

    # Create a simple secondary axis
    p + scale_y_continuous(sec.axis = sec_axis(~.+10)) +
      theme(axis.line.y = element_line(color = "red"),
            # I can modify text color but not sure about line?
            axis.text.y.right = element_text(color = "red"))

如下面的注释所示, ggplot2 theme( axis.line.y.right = element_line(color = "red"), axis.ticks.y.right = element_line(color = "red"))

As shown in comments below, full control over right axis elements is now comprised in the development version of ggplot2 theme( axis.line.y.right = element_line(color = "red"), axis.ticks.y.right = element_line(color = "red"))

推荐答案

更新:

感谢评论在下面,可以通过使用

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