根据十六进制更改颜色条 [英] Change color bars according to hex
本文介绍了根据十六进制更改颜色条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于这个情节
数据:
df <- data.frame(stock = c("google", "google", "amazon", "amazon", "amazon", "yahoo", "yahoo", "yahoo"), status = c("open", "close", "open", "buy", "close", "open", "buy", "close"), category = c("daily", "daily", "daily", "daily", "daily", "daily", "daily", "daily"), price = c(330379.36, 52324.62, 545240.22, 192574.83, 46721.34, 477658.62, 146724.44, 42721.78))
并绘制:
library(ggplot2)
ggplot(df, aes(fill=stock, y=price, x= status)) +
geom_bar(position="dodge", stat="identity") +
ggtitle("Daily") +
theme(axis.text.x = element_text(angle = 45, vjust = 0, hjust=0)) +
geom_text(aes(label=price), position = position_dodge(width= 1), vjust=1) + coord_flip()
如何使用这种特定的十六进制来更改股票的颜色:
How can somenone change the colors of stock using this specific hex:
google #ff53aa
amazon#492ecb 雅虎#5041ae
amazon #492ecb yahoo #5041ae
推荐答案
以这种方式尝试
ggplot(df,8 aes(fill=stock, y=reorder(price, status), x= status)) +
geom_bar(position="dodge", stat="identity") +
ggtitle("Daily") +
theme(axis.text.x = element_text(angle = 45, vjust = 0, hjust=0)) +
geom_text(aes(label=price), position = position_dodge(width= 1), vjust=0.5) +
scale_fill_manual(values = c("#492ecb", "#5041ae", "#ff53aa")) +
coord_flip()
这篇关于根据十六进制更改颜色条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文