r - plotly_build modifies legend and labels -


i have problem when transforming ggplot2 graph plotly.

here reproducible code:

library(ggplot2) library(plotly)  # build data  dgraf<-data.frame(num=seq(0,2*pi,length.out=100),                    name=sample(apply(expand.grid(letters,letters),1,function(x) paste(x,collapse="\n")),100),stringsasfactors = f) dgraf$y<-sin(dgraf$num) rpoint<-sample(25:75,1) dgraf$ypoint<-na dgraf$ypoint[rpoint]<-dgraf$y[rpoint] dgraf$ymin<-na dgraf$ymin[1:rpoint]<-runif(1,0.25,0.75) dgraf$ymax<-na dgraf$ymax[rpoint:100]<-runif(1,-0.75,-0.25)  # ggplot  labels<-c("data y","breaking point","lower line","higher line") shapes<-c(21,21,na,na) colors<-c("grey","white","cyan","green") fills<-c("black","red","black","black") sizes<-c(3,4,1,1) linetypes<-c("solid","blank", "solid", "dashed")  dgrafgg<-reshape2::melt(dgraf,id.var="num", measure.var=c("y", "ypoint", "ymin", "ymax"))  gplot<-ggplot(dgrafgg) +   geom_line(aes(x=num,y=value,group=variable, color=variable, linetype=variable),size=1.2) +   geom_point(aes(x=num,y=value,group=variable, color=variable, size=variable, fill=variable, shape=variable), color="white", stroke = 0.1) +   scale_shape_manual(values=shapes, name="legend", labels=labels) +    scale_color_manual(values=colors, name="legend", labels=labels) +   scale_fill_manual(values=fills, name="legend", labels=labels) +   scale_size_manual(values=sizes, name="legend", labels=labels) +   scale_linetype_manual(values=linetypes, name="legend", labels=labels) +    scale_x_continuous(breaks = dgraf$num[seq(1,100,by=10)], labels = dgraf$name[seq(1,100,by=10)]) +   labs(title = "main title", x = "x", y = "y") +    ggthemes::theme_few() gplot 

ggplot2 graph

# plotly  gplotly <- plotly_build(gplot) gplotly 

plotly graph

about ggplot2 graph:

how remove border (color="white", stroke = 0.1) points?

about plotly version:

why legend modified?

why x.axis labels modified?

why geom_lines modified , white points shown in graph?

to change legend label after plotly_bluid(gplot) can change gplot information ggplo$x$data[[i]]$name , ggplo$x$data[[i]]$legendgroup.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -