Not sure if this is what you are looking for?
library(plotly)
restaurants_per_area %>%
plot_ly(
x = ~air_area_name,
y = ~n, type = 'bar',
color = ~n,
colors = c("lawngreen", "red"),
height = 1000) %>%
layout(
title = list(
text = 'The number of restaurants at each location',
font = list(color = 'steelblue', size = 25),
y = 0.97
),
xaxis = list(title = "Air Area Name", categoryorder = 'total ascending', color = 'green'),
yaxis = list(title = 'Number of Restaurants', color = 'green')
)
Or categorical coloring:
library(plotly)
restaurants_per_area %>%
plot_ly(
x = ~air_area_name,
y = ~n, type = 'bar',
color = ~air_area_name,
height = 1000) %>%
layout(
title = list(
text = 'The number of restaurants at each location',
font = list(color = 'steelblue', size = 25),
y = 0.97
),
xaxis = list(title = "Air Area Name", categoryorder = 'total ascending', color = 'green'),
yaxis = list(title = 'Number of Restaurants', color = 'green')
)