目錄R語言之可視化①誤差棒R語言之可視化②點圖R語言之可視化③點圖續(xù)R語言之可視化④點韋恩圖upsetRR語言之可視化⑤R圖形系統(tǒng)R語言之可視化⑥R圖形系統(tǒng)續(xù)R語言之可視化⑦easyGgplot2散點圖R語言之可視化⑧easyGgplot2散點圖續(xù)R語言之可視化⑨火山圖R語言之可視化⑩坐標系統(tǒng)R語言之可視化①①熱圖繪制heatmapR語言之可視化①②熱圖繪制2R語言之可視化①③散點圖+擬合曲線R語言之可視化①④一頁多圖(1)R語言之可視化①⑤ROC曲線R語言之可視化①⑥一頁多圖(2)R語言之可視化①⑦調色板R語言之可視化①⑧子圖組合patchwork包R語言之可視化①⑨子ggplot2中的圖例修改======================= 正文自定義ggplot2圖的圖例,。這里我們要修改非數(shù)據(jù)組件,,通常通過 library(ggplot2)basic=ggplot(mtcars, aes(wt, mpg, colour = factor(cyl), shape = factor(vs) )) + geom_point()basic image.png
basic+labs( colour = "name1", shape = "name2") image.png
basic + guides(shape=FALSE) image.png 修改圖例位置要刪除圖例,,請在 #1: no legend basic + theme(legend.position = "none") #2: around the plot basic + theme(legend.position = "bottom") #3: inside the plot basic + theme( legend.position = c(.95, .95), legend.justification = c("right", "top"), legend.box.just = "right", legend.margin = margin(6, 6, 6, 6) ) 一些自定義圖例的測試# 圖例被紅框包裹 basic + theme(legend.box.background = element_rect(color="red", size=2),legend.box.margin = margin(116, 6, 6, 6)) # 圖例中指示圖標的邊框設置 basic + theme(legend.key = element_rect(fill = "white", colour = "black")) #圖例中的字體設置 basic + theme(legend.text = element_text(size = 8, colour = "red")) # 設置圖例中的標題 basic + theme(legend.title = element_text(face = "bold")) |
|