1
드릴링 프로파일을 나타내는 여러 개의 누적 기둥 형 차트가 있습니다. 은지면의 실제 높이를 나타 내기 위해 각 시추공의 y 위치를 오프셋 ()하고 싶습니다.ggplot2를 사용하여 스택 된 열 플롯에 수직 옵셋 추가
내 데이터는 다음과 같습니다는
x layer.thickness layer.depth Petrography BSCategory Offset
0 0.2 0.2 silt Drilling1 0
0 1.0 1.2 gravel Drilling1 0
0 3.0 4.2 silt Drilling1 0
4 0.4 0.4 silt Drilling2 -1
4 0.8 1.2 gravel Drilling2 -1
4 2.0 3.2 sand Drilling2 -1
내 최소한의 작업 코드는 지금까지 있습니다 : 빨간색이 지금까지 내 출력
df <- data.frame(x=c(0,0,0,4,4,4), layer.thickness = c(0.2,1.0,3.0,0.4,0.8,2.0),
layer.depth = c(0.2,1.2,4.2,0.4,1.2,3.2),
Petrography = c("silt", "gravel", "silt", "silt", "gravel", "sand"),
BSCategory = c("Drilling1","Drilling1","Drilling1","Drilling2","Drilling2","Drilling2"),
Offset = c(0,0,0,-1,-1,-1))
# provide a numeric ID that stops grouping individual petrography items
df <- transform(df,ix=as.numeric(factor(df$BSCategory)));
drilling <- ggplot(data = df, aes(x = x, y = layer.thickness, group = ix, fill = Petrography)) +
theme_minimal() +
theme(axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
axis.line.x = element_blank(),
axis.ticks.y = element_line(),
aspect.ratio=1) +
geom_col(position = position_stack(reverse = TRUE), width= .15,color="black") +
scale_y_reverse(expand = c(0, 0), name ="Depth [m]") +
scale_x_continuous(position = "top", breaks = df$x, labels=paste(df$BSCategory,"\n",df$x,"m"), name="") +
scale_fill_manual(values = c("gravel"='#f3e03a', "sand"= '#e09637', "silt"='#aba77d'))
print(drilling)
(그것이 무엇을 나타내는 다음과 같이 표시되어야 함) :
대단히 감사합니다! 다른 모든 사람들을 위해서 : 나는 두 개의 추가 된'geom_segments'를 더 추가하여 검은 색 테두리 모양을 만들었습니다. 질문에있는 이미지는 다음과 같습니다 : 'geom_segment (x =, xend, (x), xend = (x), y = start-0.014) , yend = end + 0.014), size = drill_width + 1, color = "black") + geom_segment (size = drill_width) + geom_segment (크기 = drill_width, color = "black", aes (y = 시작 -0.114, yend = start, x = x, xend = x)) + ...' – Valentin