zoukankan      html  css  js  c++  java
  • R语言-ggplot原点设置

    ggplot2绘图结果往往X轴和Y轴的截距交点往往不是原点:譬如下图y轴就不是起始于0

    attachments-2018-09-SIlQg6r35ba4ae7fd6337.jpg

    调整坐标起始位点可以利用scale_y_continuous(expand = c(0, 0))或者scale_x_continuous(expand = c(0, 0))

    expand的解释如下

    expand

    A numeric vector of length two giving multiplicative and additive expansion constants. These constants ensure that the data is placed some distance away from the axes. The defaults are c(0.05, 0) for continuous variables, and c(0, 0.6)for discrete variables.

    连续性和离散型都涉及,默认值不同,离散型scale_y_discrete 或者scale_x_discrete,这里针对连续性进行介绍:

    参考画图数据和代码   http://www.omicsclass.com/article/92

    修改y轴连续性坐标起点:y = p + scale_y_continuous(expand=c(0,0))

    attachments-2018-09-ZIFUvBjK5ba4b3525c768.jpg

    如果针对x离散型的调整呢?尝试调整数,使柱子紧贴Y轴:x = p + scale_x_discrete(expand=c(0,0))

    attachments-2018-09-5mmJ7gMJ5ba4b40f78975.jpg
  • 相关阅读:
    基本排序
    mysql安装
    函数和方法
    COOKIE 与 SESSION
    django---入门
    django模板继承
    2017-11-14
    Django---模板层(template)
    Dajngo---model基础
    Django--基础篇
  • 原文地址:https://www.cnblogs.com/xiaofeiIDO/p/10858410.html
Copyright © 2011-2022 走看看