目前,我正在使用ggplot2制作密度图。
ggplot(data=resultFile,aes(x=V19, colour=V1) ) +
geom_line(stat="density") +
xlab("score") +
ylab("density") +
ggtitle(paste(data_name,protocol,level,sep=" ")) +
theme(legend.title=element_blank(), legend.position=c(0.92,0.9)) +
scale_color_manual(values=c("blue","red"),
labels=c("A", "B"))
使用这段代码,我可以得到下面的图表。
![enter image description here](https://istack.dev59.com/MzRmC.webp)
![enter image description here](https://istack.dev59.com/f3Jap.webp)
如何使ggplot的图表看起来像R中的plot(density()...)?
plot.default
函数,则需要将xlim
参数指定为xlim=c(0,##)
,其中##表示要表示的最大值。 - ccapizzano