简体   繁体   中英

Labeling the scatterplot point in boxplot And the summary of the boxplot in the graph in R

Bonjour All,

I need help to find a solution to labeling the scatterplot in boxplot.

As you can see below, there is two data, first is the data of all macrocosmes, and second is the mean each macrocosmes.

Tab1 // query result

  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 

means
1 15.43801 15.38659 15.23252 15.50707 15.67684 15.25383

My problem is, how to show the label in each point in the graph two. i want to labeling each point with their no.macrocosme.

This is my little code :

#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))

I have tried with function text() --> show the number in the boxplot not in the scatterplot, and package textxy() --> not show anything

I guess there is a problem when i determine the x,y values.. hmm.. Is there possible, that we show the summary of each boxplot in the graph (median, Q1 -Q3)?

This is the graph that i produce : As you can see below, there is two graphs, the right side is the boxplot of all macrocosmes with the mean values, and the left side is the boxplot with scatter plot of all mean the macrocosmes.

带箱图的我的图和带一维散点图的所有箱图的均值 Thanks before for your help..

Regards,

Yougyz

The text function should work find. For example,

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

In your example, try something like:

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

This should display letters at the red dots. However, in your call to the strip chart function, you have "jittered" or "wiggled" the points. Since you've only a few points, don't jitter them (probably omit the method argument), and the following should work:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM