2
ggplot의 다른 위치에 틱과 레이블을 만드는 방법을 찾고 있습니다.ggplot 축 틱과 레이블을 개별적으로 표시합니다.
샘플 코드이 그림에서
#load libraries
library(ggplot2)
library(reshape2)
#create data
df <-data.frame(A=1:6,B=c(0.6,0.5,0.4,0.2,0.3,0.8),C=c(0.4,0.5,0.6,0.8,0.7,0.2),D=c("cat1","cat1","cat1","cat2","cat2","cat2"))
df
df1 <- melt(df,measure.vars=c("B","C"))
#plot
p <- ggplot()+
geom_bar(data=df1,aes(x=A,y=value,fill=variable),stat="identity")+
theme(axis.title=element_blank(),legend.position="none")
print(p)
는 기본 (휴식에 의해 정의) 같은 위치에있는 진드기와 라벨이 있습니다. 그리고 테마 때문에 X 축 선이 모두 누락되었습니다.
대신에, 나는이 위치이 위치
lpoint <- data.frame(pos=c(2,5),lab=c("cat1","cat2"))
그리고 부분의 x 축 라인이나 함께 아래와 같은 결국 그림 뭔가
tpoint <- c(1,3,4,6)
및 라벨에 틱을하고 싶습니다 전체 x 축 라인 :
이 자리
p1 <- p + scale_x_discrete(breaks=lpoint$pos,labels=lpoint$lab)
내 레이블을두고 그러나 진드기가 잘못된 장소에 여러 스케일은 불가능?
: P2 <- P + facet_wrap를 (~ D = "free_x을"확장) – Mahrtynas