단일 서브플롯 행이 아닌 전체 그림을 덮기 위해 Y축 제목 "수천 명"을 어떻게 추가합니까? 아래 이미지는 플롯의 경우 하단에 scrunched y축 제목을 보여줍니다. 하위 플롯 행의 중앙이 아닌 전체 차트의 중앙에 있는 단일 y축 레이블을 원합니다. 보너스: 레이아웃을 허용하면서 y축 제목 방향을 유지합니다(autosize = TRUE).
library(plotly)
plotList <- function(nplots) {
lapply(seq_len(nplots), function(x) {
plot_ly(economics, x = ~date, y = ~unemploy)%>%
add_annotations(
text = ~paste("Plot ",x),
x = 0.5,
y = 1.1,
yref = "paper",
xref = "paper",
xanchor = "middle",
yanchor = "top",
showarrow = FALSE)
}
)
}
s1 <- subplot(plotList(4), nrows = 4, shareX = TRUE, shareY = TRUE, titleY = FALSE, margin = .01)
s2 <- subplot(plotList(2), shareY = TRUE)
fig <- subplot(s1, s2,
plot_ly(economics, x = ~date, y = ~unemploy)%>%
layout(yaxis = list(title = 'Total Unemployed Persons')),
nrows = 3,
margin = 0.04, heights = c(0.6, 0.3, 0.1),
titleY = TRUE)
fig
원함 차트 : : 이러한 링크는 대답하려고 사람이 도움이 될 수 있습니다 R plotly 지역 사회 및 plotly 파이썬 커뮤니티
비슷한 질문이 Python에 대해 묻고 답변되었습니다. 솔루션은 R에서도 동일합니다. 표준 축 레이블을 삭제하고 원하는 정보를 대신 주석으로 표시하기만 하면 됩니다. 다음 그림은 아래의 미리보기 및 삽입에 수직 주석에 의해 생산 y=0.5
및x=-0.2
library(plotly)
fig1 <- plot_ly(economics, x = ~date, y = ~unemploy)
fig1 <- fig1 %>% add_lines(name = ~"unemploy")
fig2 <- plot_ly(economics, x = ~date, y = ~uempmed)
fig2 <- fig2 %>% add_lines(name = ~"uempmed")
fig <- subplot(nrows=2,fig1, fig2)
# make room for both main title and y-axis titles
m <- list(
l = 100,
r = 25,
b = 25,
t = 125
#pad = 4
)
fig <- fig %>% layout(title=list(text='Main figure title', font = list(color = "red",size = 24)),
autosize = F,
#width = 500, height = 500,
margin = m)
# your axis title
fig <- fig %>% layout(annotations = list(
list(x = -0.15 , y = 0.5, text = "Thousands of people",
font = list(color = "blue",size = 18),
textangle = 270,
showarrow = F, xref='paper', yref='paper', size=48)
))
fig
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다