1

I'm recently trying to make some nice interactive plots using iplots and qtlcharts, but didn't manage to find a feasible solution to add labels or legends on it. Anyone knows how to add text to an interactive plot in R?

Below are some codes for testing.

library(qtlcharts)
x <- rnorm(100)
grp <- sample(1:3, 100, replace=TRUE)
y <- x*grp + rnorm(100)
iplot(x, y, grp)

Is there some function like: plot(x, y); text(0,0, labels = "test") for adding text to interactive plot?

edit: Thanks Rafael and TheBiro for the answers. Basically, I wanted to add a permanent text (and maybe lines as well) in the interactive plot like what we achieve using text() in normal plots. Correspondent code in normal plot:

plot(x, y); text(-2,0, labels = "test");abline(h=-1)

Is it possible?

4

2 回答 2

1

您要添加的文本是什么?是绘图中每个点的信息“X”、“Y”和“组”吗?

尝试这个:

iplot(x, y, grp, 
  indID = paste("x =", round(x,1),  "<br/>",
                "y =", round(y, 1), "<br/>", 
                "group =", grp))
于 2017-05-04T20:03:10.257 回答
0

你可以labels这样添加:

iplot(x, y, grp, chartOpts=list(xlab="X Label", ylab="Y Label"))
于 2017-05-04T19:58:04.017 回答