Add Points

library(plotly)dat1<-data.frame(sex=factor(c("Female","Female","Male","Male")),time=factor(c("Lunch","Dinner","Lunch","Dinner"),levels=c("Lunch","Dinner")),total_bill=c(13.53,16.81,16.24,17.42))# Map sex to different point shape, and use larger points
p<-ggplot(data=dat1,aes(x=time,y=total_bill,group=sex,shape=sex))+geom_line()+geom_point()p<-ggplotly(p)# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link=plotly_POST(p,filename="geom_line/larger")chart_link

Styles & Themes

library(plotly)dat1<-data.frame(sex=factor(c("Female","Female","Male","Male")),time=factor(c("Lunch","Dinner","Lunch","Dinner"),levels=c("Lunch","Dinner")),total_bill=c(13.53,16.81,16.24,17.42))p<-ggplot(data=dat1,aes(x=time,y=total_bill,group=sex,shape=sex,colour=sex))+geom_line(aes(linetype=sex),size=1)+# Set linetype by sex
geom_point(size=5)+# Use larger points, fill with white
scale_colour_hue(name="Sex",# Set legend title
l=30)+# Use darker colors (lightness=30)
scale_shape_manual(name="Sex",values=c(22,21))+# Use points with a fill color
scale_linetype_discrete(name="Sex")+xlab("Time of day")+ylab("Total bill")+# Set axis labels
ggtitle("Average bill for 2 people")+# Set title
theme_bw()p<-ggplotly(p)# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link=plotly_POST(p,filename="geom_line/themes")chart_link

Mapping to Groups

library(plotly)# Data frame with two continuous variables and two factors
set.seed(0)x<-rep(1:10,4)y<-c(rep(1:10,2)+rnorm(20)/5,rep(6:15,2)+rnorm(20)/5)treatment<-gl(2,20,40,labels=letters[1:2])replicate<-gl(2,10,40)d<-data.frame(x=x,y=y,treatment=treatment,replicate=replicate)p<-ggplot(d,aes(x=x,y=y,colour=treatment,group=interaction(treatment,replicate)))+geom_point()+geom_line()p<-ggplotly(p)# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link=plotly_POST(p,filename="geom_line/groups")chart_link