【问题标题】:Labeling the scatterplot point in boxplot And the summary of the boxplot in the graph in R在箱线图中标记散点图和R中图表中箱线图的摘要
【发布时间】:2012-04-03 22:08:36
【问题描述】:

您好,

我需要帮助来找到在箱线图中标记散点图的解决方案。

如下图,有两个数据,第一个是所有大宇宙的数据,第二个是每个大宇宙的平均值。

Tab1 //查询结果

      1       2       3       4       5       6
1   13.2089 13.3161 13.2497 13.2268 13.2209 11.6036
2   13.2923 13.3869 13.2950 13.2876 13.2922 11.7044
3   13.4493 13.5394 13.4450 13.4735 13.4689 11.9483

表示
1 15.43801 15.38659 15.23252 15.50707 15.67684 15.25383

我的问题是,如何在图表二的每个点上显示标签。我想用它们的 no.macrocosme 标记每个点。

这是我的小代码:

#Macrocosme
Mac = svalue(cbMacro)

#Add boxplots to all Macs
par(mfrow = c(1, 2))
boxplot(Tab1, main="Temperature of Macrocosme", xlab="No. Macrocosme", ylab="Temperature in Celcius", col=(c("gold","darkgreen")),ylim=range(c(min(vmin),max(vmax))))
points(1:length(Mac), means,pch = 22)

#Add boxplots to a median of all Macs
boxplot(means, main="Mean Temperature of all the Macrocosme", xlab="Mean", ylab="Temperature in Celcius")
with(Tab1, stripchart(means, method="jitter", vertical=TRUE, add=TRUE, col="red",pch = 20))

我尝试过使用函数 text() --> 在箱线图中显示数字而不是在散点图中,并且包 textxy() --> 不显示任何内容

我想当我确定 x,y 值时会出现问题.. 嗯.. 是否有可能,我们在图中显示每个箱线图的摘要(中值,Q1 -Q3)?

这是我生成的图表: 如下图所示,有两张图,右边是所有宏观宇宙平均值的箱线图,左边是所有宏观宇宙平均值的散点图箱线图。

之前感谢您的帮助..

问候,

尤吉兹

【问题讨论】:

    标签: r label scatter-plot boxplot


    【解决方案1】:

    文本功能应该可以找到。例如,

    R> x = rnorm(10)
    R> boxplot(x, ylim=c(-3, 3))
    R> text(1, 1, "Hi", col=2)
    

    在您的示例中,请尝试以下操作:

    text(1, means, LETTERS[length(means)], col=2)
    

    这应该在红点处显示字母。但是,在您调用带状图函数时,您已经“抖动”或“摆动”了这些点。由于您只有几个点,因此不要抖动它们(可能省略方法参数),以下应该可以工作:

    text(1.3, means, LETTERS[length(means)], col=2)
    

    【讨论】:

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