0
ggplot2
에 새로운 geom
을 만들어서 많은 수의 선을 그려야합니다. 그러나, 내 문제는 그려진 선이 정확하지 않다는 것입니다. 다음은 내 문제에 대한 간단한 설명입니다. 이 예ggplot2에서 새 기하 구조를 만들 때 데이터를 축척하는 방법은 무엇입니까?
GeomLine1 <- ggproto("GeomLine1", Geom,
required_aes = c('x','y'),
default_aes = aes(colour = "black"),
draw_key = draw_key_abline,
draw_panel = function(data, panel_scales, coord) {
grid::linesGrob(x=data$x,y=data$y,default.units = 'native')}
)
geom_line1 <- function(mapping = NULL, data = NULL, stat = "identity",
position = "identity", na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE, ...) {
layer(
geom = GeomLine1, mapping = mapping, data = data, stat = stat,
position = position, show.legend = show.legend, inherit.aes = inherit.aes,
params = list(na.rm = na.rm, ...)
)
}
이것은 선을 그어야한다 geom_line1
라는 새로운 기하 구조입니다 고려. 이 코드의
dat <- data.frame(x = c(0,10), y = c(0,10))
ggplot(dat,aes(x,y))+geom_line1() + geom_point()
출력
당신은 선이 그 위치에있는 점 이상으로 확대하고 볼 수 있습니다. 기본 기능 geom_line
을 사용하면 완벽합니다. 내 코드에서 무엇이 잘못 되었습니까? 또한 누군가가 새로운 기하학을 작성하기위한 좋은 지침서를 제안 할 수 있다면 좋을 것입니다.
ggplot(dat,aes(x,y))+geom_line() + geom_point()
[튜토리얼 (http://docs.ggplot2.org/dev/vignettes/extending-ggplot2.html). – Axeman
@Axeman 나는 그 행운을 읽었습니다. 감사합니다. – Koundy
'geom_line1'과'geom_line'의 소스를 비교 했습니까? – Axeman