Tin le Mini Lesson 8 Working with plotly

loading data

library(ggplot2)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

creating graph

g1 <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
  geom_point(alpha = 0.4) +
  geom_text(check_overlap = TRUE)

g1

adding plotly to the mix

p1 <- ggplotly(g1)
p1

possible solution for mini lesson 7

solution for overlapping points

g2 <- ggplot(mtcars, aes(x = wt, y =  mpg, fill = cyl)) +
  geom_label(label= rownames(mtcars), nudge_x = 0.25, nudge_y = 0.2, color = "white", size = 3)
g2

Adding plotly

p2 <- ggplotly(g2)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLabel() has yet to be implemented in plotly.
##   If you'd like to see this geom implemented,
##   Please open an issue with your example code at
##   https://github.com/ropensci/plotly/issues
p2

### geom_label not yet implemented in plotly # :(