【问题标题】:Density plot - how to change frequency on x-axis密度图 - 如何改变 x 轴上的频率
【发布时间】:2019-03-30 01:18:56
【问题描述】:

我创建了下面的代码来生成密度图,但是 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)

【问题讨论】:

标签: r density-plot


【解决方案1】:

添加一行:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    • 2019-09-24
    • 2017-12-26
    • 1970-01-01
    • 2014-05-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多