【发布时间】:2011-09-26 08:19:46
【问题描述】:
这是来自ggplot wiki的ggplot:
baseplot <- ggplot(data.frame(x=1:10, y=10:1)) +
geom_point(aes(x = x, y = y))
baseplot
问题
是否可以单独控制这些轴,例如只使 x 轴变黑? axis.line.x 和 axis.line.y 似乎不在选项之列。
我尝试过的
-
wiki 演示了,例如,可以控制轴的颜色
baseplot + opts(axis.line = theme_segment(colour = 'black', size = 2)) -
使用
geom_segment可以工作,但存在线条必须与情节编号匹配的限制。有没有办法得到,例如
baseplot对象的最大和最小轴以及刻度?这将减少潜在的错误。 更新这个问题的答案,“不,还没有”,已覆盖previously。baseplot + geom_segment(aes(x = c(0,0), y = c(0,0), yend = c(0, max(y)), xend = c(max(x), 0), size = c(0.5, 0.1))) + geom_segment(aes(x = 0, y = y, xend = -1, yend = y, size = 0.1))
【问题讨论】: