If the scale is continuous, then you can change the default palette using scale_fill/color_continuous
# default
ggplot(mpg,aes(cyl,displ))+geom_bar(stat="identity")
ggplot(mpg,aes(cyl,displ,fill = cyl))+geom_bar(stat="identity")
# color palette - Viridis
ggplot(mpg,aes(cyl,displ,fill = cyl))+geom_bar(stat="identity")+scale_fill_continuous(type = "viridis")
# Assign color to pallete manually
ggplot(mpg,aes(cyl,displ,fill = cyl))+geom_bar(stat="identity")+scale_fill_gradient(low = "red",high = "green")
If the scale is discrete, then you can provide the colors using
# default
ggplot(mpg[1:20,],aes(x=model))+geom_point(stat="count")
ggplot(mpg[1:20,],aes(x=model,color = model))+geom_point(stat="count")
# ColorBrewer - palette options/color.
ggplot(mpg[1:20,],aes(x=model,color = model))+geom_point(stat="count")+scale_color/fill_brewer(palette = "Set1")
Hope it helps!