R { ggplot2 } 是否可以查询绘图的刻度线是什么?
使用 Hadley 网站 中的示例:
> (m <- qplot( rating, votes, data=subset(movies, votes > 1000), na.rm = T))
创建:
我的问题:创建绘图对象后是否可以确定刻度线标记的内容? (我想删除第一个自动生成的断点)
背景:在上图中,可以清楚地看到 x 轴断点位于 2 到 9 处。要手动获取此断点,请使用:
< code>m +scale_x_continuous(breaks = c(2:9))
但我想从图中确定刻度线是什么,以便我可以删除其中一些刻度线。换句话说,是否有一个函数会返回刻度线:
myBreaks <-tickMarks(m)
以便我可以随后调用:
m + scale_x_continuous(breaks = myBreaks[-1 ] )
我已经从数组中删除了第一个中断。
Using the example from Hadley's website:
> (m <- qplot(rating, votes, data=subset(movies, votes > 1000), na.rm = T))
Which creates:
My Question: Is it possible to determine what the ticks marks after creating the plot object? (I want to remove the first auto-generated breakpoint)
Background: In the above plot, one can clearly see that the x-axis breaks are at 2 through 9. To obtain this manually, use:
m + scale_x_continuous( breaks = c(2:9) )
But I would like to determine, from the figure, what the tick marks are so that I can remove some of them. In other words, is there a function which will return the tick marks:
myBreaks <- tickMarks(m)
So that I can subsequently call:
m + scale_x_continuous( breaks = myBreaks[-1] )
where I've removed the first break from the array.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否是您想要的,但您可以通过以下方式进行破解:
但请注意,这也会影响 y 轴...
并且可能这是制作您自己的变换对象的简单方法。
在这种情况下,它不会影响 y 轴。
I'm not sure this is what you want, but you can do a hack by:
but note that this also affects y-axis...
And probably it is the easy way to make your own transform object.
in this case, it does not affect y-axis.