【问题标题】:Setting axis intervals in ggplot在ggplot中设置轴间隔
【发布时间】:2011-11-25 14:50:38
【问题描述】:

我已经搜索过了,不敢相信我找不到它。也许我一直在问错误的问题。

我有一组数据以直方图的形式排列,xlim 为 2,000,000 美元。我正在尝试为休息时间设置 100,000 美元的间隔(而不是使用 break = c(0, 50000, 100000, etc) 手动列出每个休息时间。我如何在 ggplot 中做到这一点?休息时间(刻度)比标签更重要,因为我可能会编辑在 Illustrator 中的缩写标签(100k 等)

p <- ggplot(mcsim, aes(result))
+ scale_x_continuous(formatter = "dollar") 
+ geom_histogram(aes(y = (..count..)/sum(..count..))) + scale_y_continuous(formatter = 'percent')

谢谢!

【问题讨论】:

  • 别忘了设置 bin 宽度!

标签: r ggplot2 visualization graphing


【解决方案1】:

您可以使用breaks=seq(0, 2000000, by=100000)。实际上,您正在使用seq 来生成您不想手动输入的向量。

【讨论】:

    猜你喜欢
    • 2022-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-01
    • 2017-04-26
    • 2017-09-24
    • 1970-01-01
    相关资源
    最近更新 更多