GGPLOT - scale_viridis

Provide colour maps that are perceptually uniform in both colour and black-and-white and then convert them with ggplotly.

dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
p <-    
 ggplot(dsamp, aes(carat, price)) +
  geom_point(aes(colour = clarity))
plotly::ggplotly(p)
txsamp <- subset(txhousing, city %in%
  c("Houston", "Fort Worth", "San Antonio", "Dallas", "Austin"))
(d <- ggplot(data = txsamp, aes(x = sales, y = median)) +
   geom_point(aes(colour = city)))
plotly::ggplotly(p)
txsamp <- subset(txhousing, city %in%
  c("Houston", "Fort Worth", "San Antonio", "Dallas", "Austin"))
(d <- ggplot(data = txsamp, aes(x = sales, y = median)) +
   geom_point(aes(colour = city)))
p <-  d + scale_colour_viridis_d()
plotly::ggplotly(p)
txsamp <- subset(txhousing, city %in%
  c("Houston", "Fort Worth", "San Antonio", "Dallas", "Austin"))
(d <- ggplot(data = txsamp, aes(x = sales, y = median)) +
   geom_point(aes(colour = city)))
p <-  d + scale_colour_viridis_d("City\nCenter")
plotly::ggplotly(p)
txsamp <- subset(txhousing, city %in%
  c("Houston", "Fort Worth", "San Antonio", "Dallas", "Austin"))
(d <- ggplot(data = txsamp, aes(x = sales, y = median)) +
   geom_point(aes(colour = city)))
p <-  d + scale_colour_viridis_d(option = "plasma")
plotly::ggplotly(p)
txsamp <- subset(txhousing, city %in%
  c("Houston", "Fort Worth", "San Antonio", "Dallas", "Austin"))
(d <- ggplot(data = txsamp, aes(x = sales, y = median)) +
   geom_point(aes(colour = city)))
p <-  d + scale_colour_viridis_d(option = "inferno")
plotly::ggplotly(p)
txsamp <- subset(txhousing, city %in%
  c("Houston", "Fort Worth", "San Antonio", "Dallas", "Austin"))
p <- ggplot(txsamp, aes(x = median, fill = city)) +
  geom_histogram(position = "dodge", binwidth = 15000)
p <-  p + scale_fill_viridis_d()
plotly::ggplotly(p)
txsamp <- subset(txhousing, city %in%
  c("Houston", "Fort Worth", "San Antonio", "Dallas", "Austin"))
p <- ggplot(txsamp, aes(x = median, fill = city)) +
  geom_histogram(position = "dodge", binwidth = 15000)
p <-  p + scale_fill_viridis_d(direction = -1)
plotly::ggplotly(p)
(v <- ggplot(faithfuld) +
  geom_tile(aes(waiting, eruptions, fill = density)))
plotly::ggplotly(p)
(v <- ggplot(faithfuld) +
  geom_tile(aes(waiting, eruptions, fill = density)))
p <-  v + scale_fill_viridis_c()
plotly::ggplotly(p)
(v <- ggplot(faithfuld) +
  geom_tile(aes(waiting, eruptions, fill = density)))
p <-  v + scale_fill_viridis_c(option = "plasma")
plotly::ggplotly(p)
(v <- ggplot(faithfuld) +
  geom_tile(aes(waiting, eruptions, fill = density)))
p <-  v + scale_fill_viridis_b()
plotly::ggplotly(p)