Manipulating legend text in R plotly
问题 I have a data.frame I'd like to scatter plot using R 's plotly with two factors which I'd like to color and shape by. Here's my data: set.seed(1) df <- data.frame(x=rnorm(12),y=rnorm(12), group=c(rep(1,3),rep(2,3),rep(3,3),rep(4,3)), treatment=c(rep("A",6),rep("B",6)), stringsAsFactors=F) df$group <- factor(df$group,levels=1:4) df$treatment <- factor(df$treatment,levels=c("A","B")) Here's how I'm trying to plot: require(plotly) plot_ly(marker=list(size=10),type='scatter',mode="markers",x=~df