我有一個獨特的問題。我有 4 個人每周使用墊子跳 3 次。然后我從每周中取最大值繪制它。好吧,這 4 個人中的一個人在 2 周內無法出現,但我仍然希望將他們包含在折線圖中以進行跳轉概述,但我不斷收到錯誤訊息“錯誤:手動比例中的值不足。需要 4 個,但是只提供了3個。”
我附上了圖表的圖片以及代碼是什么。圖片中沒有包括錯過 2 周的人,所以你可以看到我想要的圖表是什么樣子,只是添加了這個人。

Jump_vel_tracking <- ggplot(Jump_tibble, aes(x = game, y = daily_max_vel, color = athlete))
scale_color_manual(values = c("red" , "blue", "purple"))
geom_point()
geom_line(aes(group = athlete))
scale_y_continuous(breaks = seq(from = 3.0, to = 3.8, by = 0.1), limits = c(3.0, 3.8))
labs(x = 'Game', y = 'Peak Velocity (m/s)', title = "Season CMJ Peak Velocity")
theme(panel.background = element_rect (fill = 'gray88', colour = 'orange'))
theme(plot.background = element_rect (fill = 'orange', color = 'orange'))
theme(panel.grid = element_blank())
theme(legend.position = 'none',
legend.title = element_blank(),
legend.background = element_rect(fill = 'orange'),
legend.key = element_rect(fill = 'orange'))
theme(axis.text.x = element_text(size = 10, angle = 0))
theme(axis.title.x=element_blank())
Jump_vel_tracking
enter code here
uj5u.com熱心網友回復:
Error: Insufficient values in manual scale. 4 needed but only 3 provided.當您沒有scale_color_manual為因子中的所有級別提供足夠的顏色時,就會發生錯誤 。
因此,如果您的athlete因子在資料集中有四個值,則您需要第四種顏色。
編輯 - 對我(作為一個稍微色盲的人)來說,紫色和藍色幾乎無法區分,所以也許選擇不同的顏色?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/315840.html
上一篇:每個變數嵌套ggplot直方圖
