答案 0 :(得分:2)
数据框
data <- data.frame(
type = c("BMW", "TOYOTA", "HONDA"),
NC = 100,
SC = 200,
NY = 150
)
绘图
library(ggplot) # Install first
library(data.table) # Install first
# Reshape data
data_melted <- melt(data, id.vars = "type")
# Now create the actual plot
ggplot(data_melted, aes(x = type, y = value, fill = variable)) +
geom_col(position = "dodge")
结果