在ggplot中设置轴间隔
我已经搜索过这个,不敢相信我找不到它。也许我一直在问错误的问题。
我有一组以直方图形式排列的数据,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')
谢谢!
中断(刻度)比标签更重要,因为我 src="https://i.sstatic.net/Ufiaq.png" alt="在此处输入图像描述">
I have searched for this and can't believe I can't find it. Perhaps I've been asking the wrong question.
I have a set of data laid out in a histogram that has a xlim of $2,000,000. I am trying to set an interval of $100,000 for the breaks (rather than manually listing out every break with break = c(0, 50000, 100000, etc)
. How can I do this in ggplot? The breaks (ticks) are more important than the labels as I'll likely edit in Illustrator an abbreviated label (100k, etc)
p <- ggplot(mcsim, aes(result))
+ scale_x_continuous(formatter = "dollar")
+ geom_histogram(aes(y = (..count..)/sum(..count..))) + scale_y_continuous(formatter = 'percent')
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
breaks=seq(0, 2000000, by=100000)
。实际上,您正在使用 seq 来生成您不想手动输入的向量。You can use
breaks=seq(0, 2000000, by=100000)
. Effectively you are usingseq
to generate that vector you don't want to type out by hand.