十六进制颜色代码:
#FF0000
R散点图代码:
ggplot(data = df, aes(x = loc, y = cars_sold)) +
geom_col(fill = "darkblue") +
coord_flip() +
labs(title = "Number of Cars Sold by Dealership") +
theme_bw() +
theme(panel.border = element_blank(), panel.grid = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "black"), legend.position = "none") +
expand_limits(y = 0) +
scale_y_continuous(limits = c(0, max(df$cars_sold) * 1.1), breaks = seq(0, max(df$cars_sold) * 1.1, by = 0.1)) +
scale_x_reverse(breaks = seq(0, 16, by = 1), labels = seq(0, 16, by = 1), limits = c(0, 16), expand = c(0, 0)) +
geom_text(aes(label = cars_sold), hjust = -0.2, color = "white", size = 3) +
guides(fill = FALSE) +
coord_flip()
这个代码将创建一个带有十六进制颜色代码的R散点图,并使用geom_col()函数将数据按颜色分组。最后,使用coord_flip()函数将坐标轴翻转,以便正确显示颜色。
领取专属 10元无门槛券
手把手带您无忧上云