[問題] ggplot繪圖問題

看板R_Language作者 (123)時間6年前 (2017/10/30 01:40), 編輯推噓1(102)
留言3則, 2人參與, 6年前最新討論串1/1
[問題類型]: 程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來) [軟體熟悉度]: 新手(沒寫過程式,R 是我的第一 [問題敘述]: 想呈現#程式2的圖形,用#程式1的方法寫卻怎麼也沒辦法上加紅色的線 想請問是哪裡出問題? 另想順便問一下,同樣都是ggplot程式 程式1跟程式2的差別在哪? ggplot()+ ggplot(diamonds, aes(x=price)) + [程式範例]: # 程式1 (無法正確顯示) ggplot()+ geom_histogram(data = diamonds, aes(x=price), binwidth = 1000)+ geom_density(y=density, color="red") # 程式2 (正確顯示) ggplot(diamonds, aes(x=price)) + geom_histogram(aes(y=..density..),binwidth = 1000) + geom_density(color="red") 謝謝各位先進 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.226.168.111 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1509298805.A.725.html

10/30 04:51, 6年前 , 1F
density又不識變數
10/30 04:51, 1F

11/03 12:58, 6年前 , 2F
我猜是圖層的關係,程式1你沒有給geom_destiny資料
11/03 12:58, 2F

11/03 12:58, 6年前 , 3F
所以畫不出來
11/03 12:58, 3F
文章代碼(AID): #1PzX9rSb (R_Language)