![](/img/trans.png)
[英]R ggplot2: Labelling a horizontal line on the y axis with a numeric value
[英]R with ggplot2 horizontal line for average
我的腳本從csv文件中讀取數據。 我正在計算平均值,但我希望將圖上的平均值看作水平線。
avg = myData$Electricity.Costs
mean(avg)
ggplot(data = myData,
aes(x = Date, y = Electricity.Costs,
group = Budget.Plan.Monthly.Amount, colours = "Budget.Plan.Monthly.Amount")) +
geom_line() +
geom_point(aes(colour = Budget.Plan.Monthly.Amount))
你能給我一些建議嗎?
ggplot(data = myData,
aes(x = Date, y = Electricity.Costs,
group = Budget.Plan.Monthly.Amount, colours = "Budget.Plan.Monthly.Amount")) +
geom_line() +
geom_point(aes(colour = Budget.Plan.Monthly.Amount))+
geom_hline(yintercept = mean(avg))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.