반응형
축, 범례 등이없는 ggplot2
바이오 컨덕터의 헥스 빈 (내가 할 수있는)을 사용하여 (png) 표시 영역 전체를 채우는 부분 (축, 레이블, 배경, 너트 없음)을 생성하고 싶습니다.
체이스의 답변에 대한 내 의견에 따라 다음을 사용하여 많은 제거 할 수 있습니다 element_blank
.
dat <- data.frame(x=runif(10),y=runif(10))
p <- ggplot(dat, aes(x=x, y=y)) +
geom_point() +
scale_x_continuous(expand=c(0,0)) +
scale_y_continuous(expand=c(0,0))
p + theme(axis.line=element_blank(),axis.text.x=element_blank(),
axis.text.y=element_blank(),axis.ticks=element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank(),legend.position="none",
panel.background=element_blank(),panel.border=element_blank(),panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),plot.background=element_blank())
.png의 가장자리있는 주위에 여전히 작은 여백이 시청 결과. 다른 사람이 해당 구성 요소를 제거하는 방법을 알고있을 것입니다.
(역사 주 : 이후 ggplot2의 버전 0.9.2, opts
사용하지 않는 언어 대신 사용합니다. theme()
그리고 교체 theme_blank()
와 함께 element_blank()
.)
다시 : 테마 등으로 옵트 변경 (게으른 사람들을 위해) :
theme(axis.line=element_blank(),
axis.text.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks=element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank(),
legend.position="none",
panel.background=element_blank(),
panel.border=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
plot.background=element_blank())
현재 답변이 불완전하거나 비효율적입니다. 결과를 달성하는 가장 짧은 방법은 다음과 가능 theme_void()
합니다.
data(diamonds) # Data example
ggplot(data = diamonds, mapping = aes(x = clarity)) + geom_bar(aes(fill = cut)) +
theme_void() + theme(legend.position="none")
결과는 다음과 가변적입니다.
그냥 제거에 관심이있는 권한 레이블 , labs(x="", y="")
트릭을 수행합니다
ggplot(data = diamonds, mapping = aes(x = clarity)) + geom_bar(aes(fill = cut)) +
labs(x="", y="")
'opts' is deprecated.
에 ggplot2 >= 0.9.2
사용
p + theme(legend.position = "none")
xy <- data.frame(x=1:10, y=10:1)
plot <- ggplot(data = xy)+geom_point(aes(x = x, y = y))
plot
panel = grid.get("panel-3-3")
grid.newpage()
pushViewport(viewport(w=1, h=1, name="layout"))
pushViewport(viewport(w=1, h=1, name="panel-3-3"))
upViewport(1)
upViewport(1)
grid.draw(panel)
이것이 당신이 원하는 것을 가지고 있습니까?
p <- ggplot(myData, aes(foo, bar)) + geom_whateverGeomYouWant(more = options) +
p + scale_x_continuous(expand=c(0,0)) +
scale_y_continuous(expand=c(0,0)) +
opts(legend.position = "none")
참고 URL : https://stackoverflow.com/questions/6528180/ggplot2-plot-without-axes-legends-etc
반응형
'IT' 카테고리의 다른 글
Python3 프로젝트는 __pycache__ 폴더 및 .pyc 파일을 제거합니다. (0) | 2020.07.11 |
---|---|
c # .net의 기존 배열에 새 항목 추가 (0) | 2020.07.11 |
react.js에서 상태 변경을 듣는 방법은 무엇입니까? (0) | 2020.07.11 |
NSNotificationCenter로 객체를 전달하는 방법 (0) | 2020.07.11 |
Swift 2에서 사용자 정의 메시지로 오류 / 예외를 발생시키는 가장 간단한 방법은 무엇입니까? (0) | 2020.07.11 |