Let’s make some plots !

nyc_airbnb %>% 
  plot_ly(x = ~lat, y = ~long, type = "scatter", mode = "markers", 
          color = ~price, alpha = 0.5)

Interactive plot showing airbnb prices in NYC neighborhoods

nyc_airbnb %>% 
  mutate(neighbourhood = fct_reorder(neighbourhood, price)) %>% 
  plot_ly(y = ~price, color = ~neighbourhood, type = "box", colors = "Set2")

Making a bar chart

First you have to make a specific dataset with what you want the y value to go up to * ex. this is a bar chart with neighborhoods and each of their counts as the y axis

nyc_airbnb %>% 
  count(neighbourhood) %>% 
  mutate(neighbourhood = fct_reorder(neighbourhood, n)) %>% 
  plot_ly(x = ~neighbourhood, y = ~n, color = ~neighbourhood, type = "bar")
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors

## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
scatter_ggplot = 
  nyc_airbnb %>%
  ggplot(aes(x = lat, y = long, color = price)) +
  geom_point(alpha = 0.25) +
  scale_color_viridis() +
  coord_cartesian() +
  theme_classic()

ggplotly(scatter_ggplot)