0
如何在ggplot2中更改Y軸。我使用這個代碼,但我得到這個錯誤:在ggplot2中設置y軸
k <- read.table(text=" name1 Ereigniss distance
kamel kamel 1,251
kamel Dumper 2,750
kamel Graben 2,702
kamel Traktor 2.716
Dumper Kamel 2,750
Dumper Dumper 2,050
Dumper Graben 2,703
Dumper Traktor 2,570
Graben Kamel 2,702
Graben Dumper 2,703
Graben Graben 0,701
Graben Traktor 2,840
Traktor kamel 2,716
Traktor Dumper 2,570
Traktor Graben 2,840
Traktor Traktor 1,026
", header=T)
ggplot(k, aes(factor(name1), distance, fill = Ereigniss)) +
geom_bar(stat="identity", position = "dodge") +
scale_fill_brewer(palette = "Set1")+
labs(x="Ereignisse",y="Distanz")+
ylim(c(0,10))
然後蔭收到此錯誤:
Discrete value supplied to continuous scale
作爲Koundy暗示必須刪除逗號作爲'distance'被視爲,當它在被讀出的字符/因子變量看'STR(k)的':距離是一個因素「。所以你需要將'distance'轉換爲數字。 – user20650