密度图-如何在X轴上更改频率

时间:2018-10-25 12:17:19

标签: r density-plot

我创建了以下代码来生成密度图,但是x轴的频率太大,即以2计。但是,我大多数数据的值都小于1,所以我希望能够更改x轴的频率。那可能吗?

my_density_plot <- data.frame(Data = Data)
b <- ggplot(my_density_plot, aes(x=Data))+ labs(title = "Density test", y = 
"Density")
b <- b + stat_density(geom = "line", alpha = 1, colour = "cornflowerblue")
print(b)

1 个答案:

答案 0 :(得分:0)

添加一行:

scale_x_continuous(breaks = c(#'s, you, want), labels = c(labels, you, want))

https://ggplot2.tidyverse.org/reference/scale_continuous.html上查看文档