Folks, please help. Tried everything. Went through different options. With factor and without, with scale_fill_manual and scale_fill_gradient... Nothing works, unfortunately :(
I created a boxplot
income.boxplot <- ggplot(income.by.state, aes(x = State, y = Estimate)) +
geom_boxplot() +
coord_flip() + scale_x_discrete(limits = rev(levels(income$State))) +
labs(title = "Median household income by state",
subtitle = "Source: 2011-2015 American Community Survey") +
theme(plot.title = element_text(hjust = 0.5)) +
labs(x = "State",
y = "Median household income",
fill = "Median household income") +
theme_fivethirtyeight() +
theme(axis.line.x = element_line(size = .5, colour = "black"),
axis.title = element_text(size = 14),
legend.position = "right",
legend.direction = "vertical",
legend.box = "vertical",
legend.key.size = unit(0.7, "cm"),
legend.text = element_text(size = 10),
text = element_text(family = "OfficinaSanITC-Book"),
plot.title = element_text(family = "OfficinaSanITC-Book"))
income.boxplot
But I cannot create a palette for it. Wanted to do orange-blue with low income as orange and goes as gradient into high/blue color.
Sometime I have Error in factor(x = State, y = Estimate) : unused argument (y = Estimate) Etc.
My data looks like
1 Ziebach County Median Household Income ($) South Dakota 35119
2 Zavala County Median Household Income ($) Texas 26672
3 Zapata County Median Household Income ($) Texas 32162
4 Yuma County Median Household Income ($) Colorado 43105
Update!
I found something. link
But when I tried to do this with color = as.integer(Estimate), group = Estimate, it became bad. So, it is possible somehow.
Update 2!
This printscreen demonstrates my desired outcome, but this is Tableau