I have this geom point, that shows the Sales Ratio of 30 towns from Connecticut, works well and this is the chart.
Once I add a color palette (last line of code), it removes 22 data rows. *Removes 21 rows containing missing values ( geom_point() ) *
Any ideas?
This is the code.
sales %>% group_by(Town) %>%
summarise(ratio_mean = mean(Sales.Ratio)) %>%
arrange(-ratio_mean) %>%
subset(ratio_mean < 3 & ratio_mean >0.1) %>%
head(30) %>%
ggplot(aes(x = ratio_mean, y = reorder(Town, ratio_mean), color=Town)) +
geom_point(size=4) +
theme_bw() +
theme(panel.grid.major.x=element_blank(),
panel.grid.minor.x=element_blank(),
panel.grid.major.y=element_line(linetype="dashed",color="gray"),
legend.position = "none")+
labs(x="Sales Ratio",y="Town",
title="Top 30 Towns with the highest Sales Ratio",
subtitle = "Units that were sold over the listed price") +
scale_color_brewer(palette = 'Greens')


As pointed out by @GeorgeSavva in his comment each brewer palette has a maximum number of colors. One option to circumvent this limitation would be to use
colorRampPalettewhich via interpolation allows to create a color palette with in general any number of colors which could then be passed toscale_color_manual.