【问题标题】:Titles in geom box plot几何箱形图中的标题
【发布时间】:2013-06-22 02:27:03
【问题描述】:

我想为我的 qqplot 图表添加 x 和 y 标签。但这并不成功。我的图表采用列标题而不是分配的标题。有人可以告诉我错误在哪里吗?我的脚本如下。

setwd("F:/Research/Fieldwork SL-data/Seed predation and seed no/Seed No")
seednumber<-read.csv(file="seed number -analysis 3.csv", header=TRUE, sep=',')
attach(seednumber)
names(seednumber)

[1] "国家" "研究.站点" "种子.编号"

ggplot(seednumber, aes(x = Study.Site, y = Seed.Number, colour = Country,xlab="Study Site", ylab="Number of seeds in a podr" )) + geom_boxplot()

【问题讨论】:

    标签: r ggplot2 boxplot


    【解决方案1】:

    aes 创建一个未评估表达式列表,描述数据中的变量如何映射到几何图形的可视属性。

    xlabylab 不计入 geoms 的可视属性,它们是定义 xy 轴的 scales 的标签。

    您可以通过多种方式定义这些

    # given a base plot
    baseplot <- ggplot(seednumber, aes(x = Study.Site, y = Seed.Number, colour = Country)) +
                geom_boxplot()
    

    1) 最简单的是使用函数labsxlabylab

    baseplot + labs(x = "Study Site", y = "Number of seeds in a podr")
    # or
    baseplot + xlab("Study Site") + ylab("Number of seeds in a podr")
    

    请注意,您可以使用labs 更改任何比例的标签(包括映射在aes 中的标签)

    2)。您可以使用相关的scale_..._... 函数更好地控制scales

    例如

    baseplot + scale_x_discrete(name = "Study Site") + 
      scale_y_continuous(name = 'Number of seeds in a podr')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-25
      • 1970-01-01
      • 1970-01-01
      • 2020-03-22
      • 2021-05-31
      • 1970-01-01
      • 2018-04-17
      • 2014-08-16
      相关资源
      最近更新 更多