I am hoping to be able to display two or more interactive bar graphs on the same screen for easy comparison but I can't seem to figure out how to do it with plotly. Right now, the code that I have can only produce regular ggplot2 graphs like so:
condo<-filter(data,Type=="Condominium")
apart<-filter(data,Type=="Apartment")
a<-ggplot(data=condo,aes(x=Quarter_Year, y=Unit.Price...psf.,fill=Market.Segment))+
geom_bar(stat='identity',position='dodge')+
ggtitle("Condo")
b<-ggplot(data=apart,aes(x=Quarter_Year, y=Unit.Price...psf.,fill=Market.Segment))+
geom_bar(stat='identity',position='dodge')+
ggtitle("Apartment")
grid.arrange(a, b, nrow = 2)
Usually, if it was only one graph, I would follow up with:
p<-ggplotly(a)
p
However, I'm not sure how to do it with 2 graphs. I have also tried:
x<-grid.arrange(a, b, nrow = 2)
p<-ggplotly(x)
p
But of course, it doesn't work either. I think it should be possible since my lecturer has done it but honestly, I can't seem to find the solution anywhere. I hope someone here knows. Thanks for the help!
Sorry for the image. It is just my lecturer's graph to help illustrate my question but if you can't see it, I hope that I have phrased my question clearly enough)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…