美文网首页
ggplot2----Guides:axes and legen

ggplot2----Guides:axes and legen

作者: 汪汪2017 | 来源:发表于2017-10-16 20:21 被阅读0次

    详细说明二级坐标轴

    This function is used in conjunction with a position scale to create a secondary axis, positioned opposite of the primary axis. All secondary axes must be based on a one-to-one transformation of the primary axes.
    这个函数需要与一个位置刻度一起使用,以创建一个与主轴相反的中轴。所有次级轴都必须建立在主坐标轴的一对一变换上。

    用法

    sec_axis(trans = NULL, name = waiver(), breaks = waiver(), labels = waiver())

    dup_axis(trans = ~., name = derive(), breaks = derive(), labels = derive())

    derive()

    参数
    trans

    A transformation formula
    一个转化的公式

    name

    The name of the secondary axis
    二级坐标轴的名称

    breaks One of:
    NULL  for no breaks
    waiver() for the default breaks computed by the transformation object
    A numeric vector of positions
    A function that takes the limits as input and returns breaks as output

    labels One of:
    NULL  for no labels
    waiver() for the default labels computed by the transformation object
    A character vector giving labels (must be same length asbreaks)
    A function that takes the breaks as input and returns labels as output

    Details

    sec_axis is used to create the specifications for a secondary axis. Except for thetrans argument any of the arguments can be set to derive() which would result in the secondary axis inheriting the settings from the primary axis. dup_axis is provide as a shorthand for creating a secondary axis that is a duplication of the primary axis, effectively mirroring the primary axis.
    sec_axis用于为二级轴创建规范。除了反式参数外,任何参数都可以被设置为derive(),这将导致二级坐标轴从主轴继承设置。dup_axis提供了一个简写,用于创建一个副轴,这是主轴的复制,有效地称为主轴的镜像。

    Examples

    p <- ggplot(mtcars, aes(cyl, mpg)) + geom_point()
    # Create a simple secondary axisp + scale_y_continuous(sec.axis = sec_axis(~.+10))


    # Inherit the name from the primary axis
    p + scale_y_continuous("Miles/gallon", sec.axis = sec_axis(~.+10, name = derive()))

    # Duplicate the primary axis
    p + scale_y_continuous(sec.axis = dup_axis())

    # You can pass in a formula as a shorthand
    p + scale_y_continuous(sec.axis = ~.^2)

    相关文章

      网友评论

          本文标题:ggplot2----Guides:axes and legen

          本文链接:https://www.haomeiwen.com/subject/mxeluxtx.html